lundi 4 avril 2016

How to get specific value/name using dimsav/laravel-translatable package

I have followed the doc. I created two tables (1. countries and 2. country_translations).

enter image description here

Now I changed the column name => key and value cause I can get the value (lang text) by query "key".

Say for example :

$r = 'DE';//App::getLocale(); // 'fr'
$germany = Country::where('code', $r)->first();

// I want to get value where key= 'contacts-last-name'
$translation = $germany->translate($r, true)->where('key', 'contacts-last-name')->value;

print_r($translation);
exit("----");

ERROR: Undefined property

How may I get specific value using new query/sub query (key).



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire