I have a two models "user" and "user_groups"
there is a relation between the two models like so:
public function usergroup()
{
return $this->hasOne('App\user_group','id','group_id');
}
I can get all users of the group "drivers" using this method.
$driversx = User::where('group_id',3)->get();
but I wanna get these users using the "group_name" field in the "user_groups" model.
how can I achieve that?