Answer the question
In order to leave comments, you need to log in
Resource API not working with linking table?
Good evening everyone!
There is a relationship between the User and his contacts, which is carried out through one to many, in UserInfo it looks like this:
public function contacts()
{
return $this->hasMany(Contact::class);
}
$arrayInfo = ContactResource::collection($info->contacts);
$arrayInfo = ContactResource::collection(Contact::where('user_id', 20)->get()) ;
Answer the question
In order to leave comments, you need to log in
So maybe some kind of hat is being made in the resource itself, how can we know, you won’t show your super secret code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question