where('id', $user->id) ->first(); $invoice = (new InvoiceService)->getUserInvoiceOfMonth($newUser); $invoice->items()->updateOrCreate( [ 'description' => $user->description, ], [ 'item_no' => 1, 'name' => $incentiveName, 'amount' => $user->amount_value_earned, 'quantity' => 1, 'issue_date' => now()->toDateString(), ] ); } protected function addIncentiveItemForVideo(User $user, StudioPlusVideo $studioPlusVideo, StudioPlusIncentive $studioPlusIncentive, string $incentiveName = '') { $newUser = User::query() ->where('id', $user->id) ->first(); $invoice = (new InvoiceService)->getUserInvoiceOfMonth($newUser); $invoice->items()->updateOrCreate( [ 'studio_plus_video_id' => $studioPlusVideo->id ], [ 'item_no' => 1, 'name' => $incentiveName, 'description' => $studioPlusIncentive->description, 'amount' => $studioPlusIncentive->amount_value_earned, 'quantity' => 1, 'issue_date' => now()->toDateString(), ] ); } }