laravel-cross-eloquent-search
laravel-cross-eloquent-search copied to clipboard
addFullText for relationships?
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 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'));
You're right, @seewhy17 :)