firstOfMonth(); $prevMonth = now()->subMonth(); // Get all vendor have completed order item this month // $query = GigOrder::query()->select(['id','author_id']) // ->where('status',GigOrder::COMPLETED) // ->where('created_at','<',$invoice_month->format('Y-m-d 00:00:00')) // ->whereNull('payout_id') // ->groupBy('author_id'); // $query->chunkById(20,function($vendors) use ($prevMonth) { // foreach ($vendors as $vendor){ // CreatePayoutForCandidateJob::dispatch($vendor->author_id,$prevMonth->format('Y'),$prevMonth->format('m')); // } // }); } }