1
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 getting the Model Pai ordination through a field ORDER of Model Filho.
That’s possible ?
I tried with Wherehas and Eager Loading, but it didn’t work out.
As a last resort Leftjoin. But first I’d like to know if there’s any other way.
Model Pai = Menuloginpermission
Model Filho = Menu
Table Field Menu = Order
Related: How to Sort Related Model Data?
– Wallace Maxters