Laravel-datatables: Method filterColumn does not exist.

Created on 12 Oct 2017  路  5Comments  路  Source: yajra/laravel-datatables

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.

question

Most helpful comment

Yeah so I removed ->get() and its working now. Thanks @xakzona

All 5 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackrsantana picture jackrsantana  路  3Comments

alejandri picture alejandri  路  3Comments

vipin733 picture vipin733  路  3Comments

shadoWalker89 picture shadoWalker89  路  3Comments

ahmadbadpey picture ahmadbadpey  路  3Comments