1
I have a relationship Polymorphic between Customer and Car Class.
Client class:
public function carros()
{
return $this->morphMany(Carro::class, 'dono');
}
Car Class:
public function dono()
{
return $this->morphTo();
}
I am doing a search and in the result the Owner’s data appears as NULL
.
$result=Carro::with('dono')->where('id',10)->get();
Now if I do the research using the Thinker
values appear normally.
Where I’m going wrong to come the NULL
as response in the OWNER. The values of the car come back right.
Try,
...where('id', 10)...
– Miguel
Sorry was the correction that added the = Aino Where. But this as you quoted. I will change. Thanks.
– Joao Nivaldo
Your problem has been solved?
– novic
@Virgilionovic I read this question you quoted and I think mine has nothing to do with her.
– Joao Nivaldo
Face for me is duplicate, because if it is not carrying something behind you did wrong, see your answer even is a problem, if there is a relationship because of Where later ???
– novic
@Virgilionovic looks the Where is for me to select a car and after selected I want to know its owner. I don’t see any error in Where.
– Joao Nivaldo
Your question is confusing ... If you’re talking.list now puts Where in the relationship. All this is not what the question says. But all right solved your problem .
– novic