i have Articles table and i have web on 3 different languages. I need search on 3 different languages, Now i'm having only one language search i did think like this.
$translations = Article::join('translations', 'articles.id', '=', 'translations.id')
->where('value', 'LIKE', "%{$request->search}%")->orderBy('published_at', 'Desc')->get();
It's search but it's search different articles, Search don't work right, What i'm doing wrong?
CodePudding user response:
In translation table, may be foreign key is translations.foreign_key
so try this:
$translations = Article::join('translations', 'articles.id', '=', 'translations.foreign_key')
->where('value', 'LIKE', "%{$request->search}%")->orderBy('published_at', 'Desc')->get();