Getting Undefined property: Laravel\Scout\Builder::$whereIns error

106 views Asked by At

I am using Laravel scout with Typesense package for searching purpose. I have self-hosted my Typesense server and then imported the Model on scout but when i try to access the data, I'm getting this error.

enter image description here This is the query that giving me error

$result = Todo::search('test')->get();

i have added these following methods on my Todo model

public function toSearchableArray()
{
    return array_merge(
        $this->toArray(), 
        [
            // Cast id to string and turn created_at into an int32 timestamp
            // in order to maintain compatibility with the Typesense index definition below
            'id' => (string) $this->id,
            'created_at' => $this->created_at->timestamp,
        ]
    );
}

 /**
 * The Typesense schema to be created.
 *
 * @return array
 */
public function getCollectionSchema(): array {
    return [
        'name' => $this->searchableAs(),
        'fields' => [
            [
                'name' => 'id',
                'type' => 'string',
            ],
            [
                'name' => 'title',
                'type' => 'string',
            ],
            [
                'name' => 'created_at',
                'type' => 'int64',
            ],
        ],
        'default_sorting_field' => 'created_at',
    ];
}

 /**
 * The fields to be queried against. See https://typesense.org/docs/0.24.0/api/search.html.
 *
 * @return array
 */
public function typesenseQueryBy(): array {
    return [
        'id','title'
    ];
} 

Here is the error message in text form

 #message: "Method Laravel\Scout\Builder::getCollection does not exist."

Any suggestion or help would be helpful. Thanks

0

There are 0 answers