未找到Laravel模型和参数错误

I'm very new to PHP and Laravel, I'm getting an eror that I can't make head or tail of.

  public function filtered($col, $sort = null, $search = null, $ordering='desc')
    {
        $field = $this->table . '.' . $col ; 

        Log::info('BaseModel::filtered->' . $field) ;

        $data = $this;
        // check if search variable not empty
        if ($search != null)
        {
            $data = $data->where(function ($query) use ($search){
                return $query->where($field,'like','%'.$search.'%') ;
            });

        // check if sort variable not empty
        if ($sort != null)
           {
           $sorts = explode('|', $sort);

           $data = $data->orderBy($sorts[0],$sorts[1]);
           }
        }
 ...

The code above is giving the error: Undefined variable: field. From the Log output I get this:

[2017-06-21 06:32:25] local.INFO: BaseModel::filtered->organisation.name

I've tried calling the field variable by $this->field as well, also fails. I also get the same error if i reference the $col parameter directly. Yet both $search and $sort are fine.

$data = $data->where(function ($query) use ($search, $field) { //Add extra parameters inside your use same as search.
    return $query->where($field,'like','%'.$search.'%') ;
});