in database i have this:
name_en | name_fr
When the user select french language - for example - i want to get name_fr
field, and the same thing if he chose another language
in database i have this:
name_en | name_fr
When the user select french language - for example - i want to get name_fr
field, and the same thing if he chose another language
Assuming you set locale in your application using:
if you use Eloquent, you can add to your model class accesssor:
and also mutator:
Assuming you added those functions to
Content
model you can now use:This will cause displaying and changing
name_{$lang}
if you set lang usingsetLocale