Controller
$menu = MenuLoginPermission::with('submenu')
->where('id_empresa_login', '=', $idUser)
->get();
Model MenuLoginPermission
class MenuLoginPermission extends Model
{
public function menu(){
return $this->belongsTo('App\Menu', 'id_menu', 'id');
}
public function submenu(){
return $this->hasMany('App\Submenu', 'id_menu', 'id_menu');
}
}
I'm not able to do the Model Parent order by a ORDER field of the Model Son.
Is this possible?
I tried WhereHas and Eager Loading , but it did not work.
In the latter case I will make a LeftJoin . But first, I wanted to know if you have a solution otherwise.
Parent Model = MenuLoginPermission
Child Model = Menu
Table Field Menu = Order