Why am I getting this error???
Code:
$datatable = datatables()->of(Lead::with(['vertical', 'source', 'tags', 'assignments', 'assignments.recipient', 'assignments.assign_user'])->whereNull('deleted_at')->get());
$datatable->editColumn('source.name', function ($lead) {
return $lead->source ? $lead->source->name : config('app.name');
});
$datatable->filterColumn('tags', function ($query, $keyword) {
$query->where('tags.name', 'like', '%'.$keyword.'%');
});
return $datatable->toJson();
editColumn() works perfectly fine.
No, thats for changing the default filter behavior altogether. filterColumn is for modifying the filter for a specific column:
/**
* Add custom filter handler for the give column.
*
* @param string $column
* @param callable $callback
* @return $this
*/
public function filterColumn($column, callable $callback)
{
$this->columnDef['filter'][$column] = ['method' => $callback];
return $this;
}
I have similar error but with orderColumn method and it represents only with Collection engine, with Eloquent all works fine
->orderColumn('status', 'confirmed_date $1')
I get error method does't exists
Yeah so I removed ->get() and its working now. Thanks @xakzona
@kjdion84 yes, you should remove ->get() to use eloquent. orderColumn is only available on eloquent and query builder. Glad you sorted it out!
Yeah so I removed
->get()and its working now. Thanks @xakzona
Thanks!
Most helpful comment
Yeah so I removed
->get()and its working now. Thanks @xakzona