Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Search by localized value #57

Closed
hotrush opened this issue Oct 10, 2014 · 2 comments
Closed

Search by localized value #57

hotrush opened this issue Oct 10, 2014 · 2 comments

Comments

@hotrush
Copy link

hotrush commented Oct 10, 2014

Hi. Is this possible to make request like next, when title is a translatable attribute?

Model::where('title','LIKE','%test%')->get();
@hiyahin
Copy link

hiyahin commented Oct 20, 2014

Yeah. Just found out the hard way that translated attributes cannot be queried at the moment. It would make sense to be able to, considering that when create/update the model, it automatically stops writing the original fields in model table and writes to the model's translation table instead.

At the moment, a work around would be to get the model id from the translation table and then getting the model. Not very nice, but it'll work for the moment:

$model_id = ModelTranslation::where('title', '=', 'test')->where('locale', '=', Config::get('app.locale'))->first()->model_id;
$model = Model::find($model_id);

@hotrush
Copy link
Author

hotrush commented Oct 21, 2014

thanks, will try.

@hotrush hotrush closed this as completed Oct 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants