i have a two tables where user table has a one to one relationship with role table
this is my user model
public function role(){
return $this->belongsTo(Role::class);
}
this is my role model
public function user(){
return $this->hasOne(User::class);
}
this my table structure for role
this my table structure for user
how can i access in my user model the role which is equal to employee i tried
User::with('role')->where('role_name','employee')->get();
but it has an error
role_name column not found
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire