public function scopeFilter($query, $request)
    {
        $request = Arr::only($request, ['name', 'description']);

        $query->actives()->where(function ($query) use ($request) {
            foreach ($request as $key => $value) {
                $query->orWhere($key, 'like', '%' . $value . '%');
            }
            return $query;
        });

        return $query;
    }
public function scopeFilter($query, $request)
    {
        $request = Arr::only($request, ['name', 'description']);

        $query->actives()->where(function ($query) use ($request) {
            foreach ($request as $key => $value) {
                $query->orWhere($key, 'like', '%' . $value . '%');
            }
            return $query;
        });

        return $query;
    }
public function scopeFilter ( $ query , $ request ) { $ request = Arr :: only ( $ request , [ 'name' , 'description' ] ) ; $ query -> actives ( ) -> where ( function ( $ query ) use ( $ request ) { foreach ( $ request as $ key => $ value ) { $ query -> orWhere ( $ key , 'like' , '%' . $ value . '%' ) ; } return $ query ; } ) ; return $ query ; }
Filter categories by the given request.

@param  Illuminate\Database\Eloquent\Builder $query
@param  array $request

@return Illuminate\Database\Eloquent\Builder
Filter categories by the given request .