Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App;
  4.  
  5. use Illuminate\Database\Eloquent\Model;
  6.  
  7. class Invoice extends Model
  8. {
  9. public function bulan ()
  10. {
  11. return $this->hasMany('App\Invoice', 'bill_year','bill_year');
  12. }
  13.  
  14. public function scopeWithBulan ($q, $status = 0)
  15. {
  16. return $q->whereStatus($status)->with(['bulan' => function ($q) use ($status) {
  17. $q->select('bill_month','bill_year', \DB::raw('count(id) as jumlah'))->groupBy('bill_year','bill_month')->whereStatus($status);
  18. }]);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement