uksarkar
1 year ago
3974
1
Eloquent

Call to a member function getRelationExistenceQuery() on array

Posted 1 year ago by uksarkar

I am building a search filter. The code structure like this,

<?php

namespace App\ProductSearch\Filters;

use Illuminate\Database\Eloquent\Builder;

class Name implements Filter
{
    /**
     * Apply a given search value to the builder instance.
     *
     * @param Builder $builder
     * @param mixed $value
     * @return Builder $builder
     */
    public static function apply(Builder $builder, $value)
    {
        return $builder->where('name', 'LIKE', '%' . $value . '%')->orWhereHas(['category'=> function($q) use($value){
            $q->where('name', 'LIKE', '%' . $value . '%');
        }]);
    }
}

It's giving this error Call to a member function getRelationExistenceQuery() on array

Please sign in or create an account to participate in this conversation.