Problem in making a field search by date and id

1

I've made a search field but I'm not able to search by date or by id.

The database I use is Postgres, I'm using Laravel 5.2 framework

public function scopeSearchByKeyword($query, $keyword)
{
   if ($keyword!='') {

        $query->where(function ($query) use ($keyword) {
            $query->where("nome_problema", "LIKE", "%$keyword%")
                  ->orWhere("id", "LIKE", "%$keyword")
                  ->orWhere("data_criacao", "LIKE", "%$keyword");
        });
    }
    return $query;
}
    
asked by anonymous 08.11.2016 / 02:07

1 answer

0

The "where" method appears to have been spelled wrong, try this:

public function scopeSearchByKeyword($query, $keyword)
{
   if ($keyword!='') {

        $query->where(function ($query) use ($keyword) {
            $query->where("nome_problema", "LIKE", "%" .$keyword. "%")
                  ->orWhere("id", "LIKE", "%" .$keyword. "%")
                  ->orWhere("data_criacao", "LIKE", "%" .$keyword. "%");
        });
    }
    return $query;
}
    
22.03.2017 / 15:17