src/EloquentSearchTrait.php
public function scopeSearch($query, $keyword)
    {
        $columns = $this->searchColumns();

        foreach ($columns as $column) {

            if ($columns === reset($columns)) {

                $query->where($column, 'like', "%{$keyword}%");

            }

            $query->orWhere($column, 'like', "%{$keyword}%");
        }

        return $query;
    }
public function scopeSearch($query, $keyword)
    {
        $columns = $this->searchColumns();

        foreach ($columns as $column) {

            if ($columns === reset($columns)) {

                $query->where($column, 'like', "%{$keyword}%");

            }

            $query->orWhere($column, 'like', "%{$keyword}%");
        }

        return $query;
    }
public function scopeSearch ( $ query , $ keyword ) { $ columns = $ this -> searchColumns ( ) ; foreach ( $ columns as $ column ) { if ( $ columns === reset ( $ columns ) ) { $ query -> where ( $ column , 'like' , "%{$keyword}%" ) ; } $ query -> orWhere ( $ column , 'like' , "%{$keyword}%" ) ; } return $ query ; }
Scope a query to search for a keyword.

@param \Illuminate\Database\Eloquent\Builder $query
@param string $keyword
@return \Illuminate\Database\Eloquent\Builder
Scope a query to search for a keyword .