Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- class Invoice extends Model
- {
- public function bulan ()
- {
- return $this->hasMany('App\Invoice', 'bill_year','bill_year');
- }
- public function scopeWithBulan ($q, $status = 0)
- {
- return $q->whereStatus($status)->with(['bulan' => function ($q) use ($status) {
- $q->select('bill_month','bill_year', \DB::raw('count(id) as jumlah'))->groupBy('bill_year','bill_month')->whereStatus($status);
- }]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement