laravel APi resource Call to undefined method Illuminate\Database\Query\Builder::mapInto()
The problem is that you use UserResource::collection($this->user)
and you have just one element not a collection so you can replace it with new UserResource($this->user)
like this :
return [
'id' => $this->id,
'title' => $this->title,
'slug' => $this->slug,
'bodys' => $this->body,
'users' => new UserResource($this->user),
'published' => $this->published,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
this problem is that you use UserResource::collection($this->user) its mean you are many users but and you have just one element not a collection so you can replace it with new UserResource($this->user)