Can someone explain me why I have to use the local_key in this relationship?
My table User have a primary key user_id and a unique column email My table Order have a foreign key email link the User.email column not the User primary key.
if I use
public function order() {
return $this->hasMany('App\Order', 'email');
}
this don't work
But using
public function order() {
return $this->hasMany('App\Order', 'email', 'email');
}
I recieve all the info, but couldn't understand why.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community