Closed afarral closed 4 years ago
You cannot approve a collection of models, only a single model.
$modification = Modification::with('modifiable') ->where('id',$modification_id) ->get();
You are returning a collection here. Use first
or find
instead of get
- this is covered in the Laravel documentation. Please search for answers to your questions online as they have nothing to do with this package.
See the Laravel Eloquent Collections documentation. :page_facing_up: RTFM.
I have out a button against each modification record so that the user can approve or reject, i achive this by having a route defined:
Route::get('absence/verificationApprove/{modification_id}','AbsenceController@verificationApprove')->name('absence.approve'); Route::get('absence/verificationReject/{modification_id}','AbsenceController@verificationReject')->name('absence.reject');
then in the controller function i have:
but i get the error:
Argument 1 passed to App\User::approve() must be an instance of Approval\Models\Modification, instance of Illuminate\Database\Eloquent\Collection given, called in D:\LARAVEL_GRCARE\GRCARE\Modules\HRModule\Http\Controllers\AbsenceController.php on line 102
but as far i can see the Modifcation:: should mean that the correct type is returned, but it is insisting that i an supplying a collection. I use the where as i want a single modificaton record to approved/rejected rather than all.
Where/what am i not doing correctly? Thanks Asda