If I receive data using dd($event->get()) , then the correct data is output.
$language = app()->getLocale(); $event = Event::join('event_translations', 'events.id', '=', 'event_translations.event_id') ->where('event_translations.locale', '=', $language); dd($event->get()); And if using json , then no
return response() ->json([ 'model' => $event->get(), ]); For example,
dd ($ event-> get ())
attributes: array:8 [ "id" => 27 "picture" => "cutlery.png" "created_at" => "2017-01-19 14:24:18" "updated_at" => "2017-01-19 14:24:18" "event_id" => 3 "locale" => "pl" "name" => "RESTAURACJI" "description" => "RESTAURACJI\r\n"] json
created_at:"2017-01-19 14:24:18" description:"BARMANI NA ZLECZENIE" event_id:3 id:27 locale:"pl" name:"BARMANI NA ZLECZENIE" picture:"cutlery.png" updated_at:"2017-01-19 14:24:18" For localization I use the dimsav / laravel-translatable package
Laravel 5.3
descriptionandname? - NPrestonattributesstore “original” data, and when json is formed, some attributes are transformed into methods of theEventclass, such asgetNameAttribute()andgetDescriptionAttribute(). Do you have them? - NPreston