In yajra/laravel-datatables, I want to determine that current model is soft-deleted or not. if it is deleted , a success
bootstrap class apply to row containing that model details.
this is my backend code:
$courses =
Course::select(['course_id', 'title', 'start_date', 'end_date', 'picture', 'lesson_count', 'status', 'active', 'teacher','start_date','end_date','reg_start_date','reg_end_date']);
if ($request->has('showDeleted') && $request->get('showDeleted') == 1) {
$courses = $courses->withTrashed();
}
$datatable = app('datatables')->of($courses)
->orderBy('created_at', 'desc')
//columns come here
->setRowClass(function ($course) {
return ($course->trashed() ? 'danger' : 'sdasd');
});
return $datatable->make(true);
As you see I used:
->setRowClass(function ($course) {
return ($course->trashed() ? 'danger' : ' ');
});
to apply desired class But $course->trashed
return false always for all model instances even those is not trashed.
what is best solution?