{"action":"created","issue":{"url":"https://api.github.com/repos/dimsav/laravel-translatable/issues/434","repository_url":"https://api.github.com/repos/dimsav/laravel-translatable","labels_url":"https://api.github.com/repos/dimsav/laravel-translatable/issues/434/labels{/name}","comments_url":"https://api.github.com/repos/dimsav/laravel-translatable/issues/434/comments","events_url":"https://api.github.com/repos/dimsav/laravel-translatable/issues/434/events","html_url":"https://github.com/dimsav/laravel-translatable/issues/434","id":294786528,"number":434,"title":"Can i use this package for RestFul APIs?","user":{"login":"mimrank","id":10322671,"avatar_url":"https://avatars1.githubusercontent.com/u/10322671?v=4","gravatar_id":"","url":"https://api.github.com/users/mimrank","html_url":"https://github.com/mimrank","followers_url":"https://api.github.com/users/mimrank/followers","following_url":"https://api.github.com/users/mimrank/following{/other_user}","gists_url":"https://api.github.com/users/mimrank/gists{/gist_id}","starred_url":"https://api.github.com/users/mimrank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimrank/subscriptions","organizations_url":"https://api.github.com/users/mimrank/orgs","repos_url":"https://api.github.com/users/mimrank/repos","events_url":"https://api.github.com/users/mimrank/events{/privacy}","received_events_url":"https://api.github.com/users/mimrank/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-06T14:49:49Z","updated_at":"2018-05-15T12:49:19Z","closed_at":null,"author_association":"NONE","body":"Hi, how it will return JSON data in single object with translated key inside of a child array of translations.\r\nI am trying, but its not work\r\n\r\n`// models/Country.php\r\nnamespace App\\Models;\r\n\r\nuse Dimsav\\Translatable\\Translatable;\r\nclass Country extends Eloquent {\r\n    \r\n    use Translatable;\r\n    \r\n    public $translatedAttributes = ['name'];\r\n    protected $fillable = ['code'];\r\n    \r\n    /**\r\n     * The relations to eager load on every query.\r\n     *\r\n     * @var array\r\n     */\r\n    // (optionaly)\r\n    // protected $with = ['translations'];\r\n\r\n}\r\n\r\n// models/CountryTranslation.php\r\nnamespace App\\Models;\r\n\r\nclass CountryTranslation extends Eloquent {\r\n\r\n    public $timestamps = false;\r\n    protected $fillable = ['name'];\r\n\r\n}`\r\n\r\n`In Conroller\r\n$countries = Country::translatedIn('fr')->get();\r\nreturn response()->json($countries);\r\n`\r\nIts return data in \r\n\r\n`\r\n{\r\n  \"code\": \"uk\",\r\n  \"name\": \"England\",\r\n  \"translations\": [\r\n    {\r\n      \"name\": \"England\",\r\n      \"locale\": \"en\"\r\n    },\r\n    {\r\n      \"name\": \"Angleterre\",\r\n      \"locale\": \"fr\"\r\n    }\r\n  ]\r\n}\r\n`\r\nBut i require it in this form\r\n`\r\n{\r\n  \"code\": \"fr\",\r\n  \"name\": \"Angleterre\"\r\n}\r\n`\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dimsav/laravel-translatable/issues/comments/389154399","html_url":"https://github.com/dimsav/laravel-translatable/issues/434#issuecomment-389154399","issue_url":"https://api.github.com/repos/dimsav/laravel-translatable/issues/434","id":389154399,"user":{"login":"Gummibeer","id":6187884,"avatar_url":"https://avatars1.githubusercontent.com/u/6187884?v=4","gravatar_id":"","url":"https://api.github.com/users/Gummibeer","html_url":"https://github.com/Gummibeer","followers_url":"https://api.github.com/users/Gummibeer/followers","following_url":"https://api.github.com/users/Gummibeer/following{/other_user}","gists_url":"https://api.github.com/users/Gummibeer/gists{/gist_id}","starred_url":"https://api.github.com/users/Gummibeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gummibeer/subscriptions","organizations_url":"https://api.github.com/users/Gummibeer/orgs","repos_url":"https://api.github.com/users/Gummibeer/repos","events_url":"https://api.github.com/users/Gummibeer/events{/privacy}","received_events_url":"https://api.github.com/users/Gummibeer/received_events","type":"User","site_admin":false},"created_at":"2018-05-15T12:49:19Z","updated_at":"2018-05-15T12:49:19Z","author_association":"COLLABORATOR","body":"@mimrank have you tried `getTranslationsArray`?"}}
{"actor":{"display_login":"Gummibeer"}}