I am trying to define and retrieve a relationship
In my User.php model
public function getClient() {
return $this->hasOne('\App\Client', 'id');
}
In my client model
public function contact() {
return $this->hasOne('\App\User', 'client');
}
The id of the clients table joins client table with the users table.
I try and retrieve with
$all = \App\User::with('getClient')->get();
return view('users.all')->with('all', $all);
but I do not get the results of the join only the original table.
What am I going wrong?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tCySdj
via IFTTT
Aucun commentaire:
Enregistrer un commentaire