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

Where has translation ?

ahmadyousefdev opened this issue · comments

Hi!
Is there a way to only list translated content from a model?

for example, this line

Content::where('published',true)->orderBy('created_at', 'desc')->get();

will list all the content in my model.

let's say the field title in Content model is translatable, is there a way to list all the content where title is in a specific language?

I managed to solve it like this

$locale = Config::get('app.locale');
Content::where('title->'.$locale, '<>', '')->where('published',true)->orderBy('created_at', 'desc')->get();

But is there a cleaner way supported by this package ?

Ia there another solution for this problem?

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.