Aug 16, 2019
0
Level 54
Yajra Datatables
I'm using the following package to better display a rendered table of users for my project. The problem is what I would like to do is extract the logic inside of the ajax check to a new Datatable class that extends the package's default Datatable class. The methods that I'm looking at for the class doesn't exactly line up with what I'm doing.
https://github.com/yajra/laravel-datatables
https://yajrabox.com/docs/laravel-datatables/master/editor-tutorial
public function index(IndexUserRequest $request, DataTables $table, UserFilters $requestFilter)
{
$this->authorize('viewList', User::class);
if ($request->ajax()) {
$query = User::with('employment');
$requestFilter->apply($query);
return $table->eloquent($query)
->addColumn('action', 'users.partials.action-cell')
->filterColumn('id', function ($query, $keyword) {
$query->where($query->qualifyColumn('id'), $keyword);
})
->toJson();
}
return view('users.index');
}
Please or to participate in this conversation.