I cant quite figure this out.
User hasOne Contact (model that stores the User's contact info)
Now a new User obviously has no record so $user->contact returns nothing as expected.
Yet I am Passing it thru a API Resource and still return nothing. I figured it would still return something for my front-end?
'contact' => new PublicContactResource($this->contact)
But it never hits the PublicContactResource ?
Snip:
public function toArray($request)
{
\Log::info('Hello i am here');
}
........
I still need to return the attributes for that table even if all are empty.
return [
'type' => 'contact',
'meta' => [],
'attributes' => [
'description' => $this->when($this->description, $this->description),
'email' => $this->email,
'phone' => $this->phone,
'phone_verified' => $this->phone_verified,
'email_verified' => $this->email_verified,
]
];
Basically return the response even if there is no record, beciase the front end needs those fields to determin how to function.
Any ideas?