Using optional

parent beaba0ec
...@@ -14,8 +14,8 @@ class PageTransformer extends Resource ...@@ -14,8 +14,8 @@ class PageTransformer extends Resource
'template' => $this->template, 'template' => $this->template,
'created_at' => $this->created_at->format('d-m-Y'), 'created_at' => $this->created_at->format('d-m-Y'),
'translations' => [ 'translations' => [
'title' => $this->translate(locale())->title, 'title' => optional($this->translate(locale()))->title,
'slug' => $this->translate(locale())->slug, 'slug' => optional($this->translate(locale()))->slug,
], ],
'urls' => [ 'urls' => [
'delete_url' => route('api.page.page.destroy', $this->id), 'delete_url' => route('api.page.page.destroy', $this->id),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment