Will it be correct, if I create API RESOURCES for each request. And how to make a connection between three tables in Resources. For example:
class UserResource
public function toArray($request)
{
return [
'id'=>$this->id,
'name'=>$this->name
'work'=>WorkResource::collection($this->work)//relationship between USER and WORK
]
}
class WorkResource
public function toArray($request)
{
return [
'id'=>$this->id,
'title'=>$this->title
]
}
And in class UserResource I need to return from WORK only TITLE without ID, How I can do that?