spatie / laravel-translatable

Making Eloquent models translatable

Home Page:https://spatie.be/docs/laravel-translatable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Search for Arabic records

jadayash opened this issue · comments

Hello

Am using spatie/traslatable in my project and storing arabic text in my database.
The issue is how can i search for arabic text in the translatable cols?

They are being stored in that encoding
ggggg

I am using it to store Arabic text as well. There is no problem in searching though! I believe this is UTF-32 encoded.

Since the field is json you can just query like this:

Model::query()->where('title->ar', 'like', '%'.$search.'%');

or just loop all translations in the query:

$translations = ['ar', 'en'];

$qry = Model::query();

foreach($translations as $translation) {
    $qry->where('title->'.$translation, 'like', '%'.$search.'%');
}

Thanks alot
Working Great