Using optional

parent beaba0ec
......@@ -14,8 +14,8 @@ class PageTransformer extends Resource
'template' => $this->template,
'created_at' => $this->created_at->format('d-m-Y'),
'translations' => [
'title' => $this->translate(locale())->title,
'slug' => $this->translate(locale())->slug,
'title' => optional($this->translate(locale()))->title,
'slug' => optional($this->translate(locale()))->slug,
],
'urls' => [
'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