plastic
plastic copied to clipboard
Search on Translatable model
Someone can give me a hint for the scenario where my model is in two language, the default data is saved on the main model and the translated data is saved in a another model which store many translations of different models.
I would like to know how to implement search with this solution and also when someone is searching he can see only data of his language,
Thank you
You must use the TranslationModel like other model, with "use Searchable", custom index, etc
Simple you must filter your searches because you have all language in one table:
App\Translation::search() ->match('name', $param) ->term('locale', \App::getLocale()) ->get();
in my opinion if you would add a lot of language and a lot of entry, you should split in different model/table the languages, because if you search 1 language in a table with 10 languages, the search method work with 10x items (only 1/10 needed)