laravel-cross-eloquent-search icon indicating copy to clipboard operation
laravel-cross-eloquent-search copied to clipboard

addFullText for relationships?

Open Casmo opened this issue 2 years ago • 1 comments

Can I full search in a related model?

E.g.

$conversations = Search::addFullText(Conversation::class, ['messages.body', 'messages.subject'], ['mode' => 'boolean'])
            ->paginate(10)
            ->search(request('search'));

The error I receive is: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'messages.body' in 'where clause'

Casmo avatar May 18 '22 12:05 Casmo

@Casmo Just looking at the documentation https://github.com/protonemedia/laravel-cross-eloquent-search#full-text-search I think it should look more like so

$conversations = Search::addFullText(Conversation::class, [
    'messages' => ['body', 'subject']
], ['mode' => 'boolean'])
            ->paginate(10)
            ->search(request('search'));

thecyrilcril avatar Jul 30 '22 08:07 thecyrilcril

You're right, @seewhy17 :)

pascalbaljet avatar Dec 12 '22 09:12 pascalbaljet