In a multilingual website I have these fields for Products table
product_id
title_fa
title_en
title_ar
desc_fa
desc_en
desc_ar
.
.
.
Now I want to search in (for Example) title fields based on Current laravel Locale. I know that we can use this way :
$products = Product::where('title_'.App::getLocale(),'LIKE' , '%'.$data['search_value'].'%');
But I thinks that is not clean and easy for number of large fields is not suitable.
I'm looking for a way that was and simple as normal search field and then laravel search based on that field in background According to current App Locale like:
$products = Product::where('title','LIKE' , '%'.$data['search_value'].'%');
How Can I do that and what is best way ?