I don't know which model 'submenu' columns belongs to. If it belongs to Menu model:
$menus = Menu::whereHas('roles', function($q)
{
$q->where('id', 4);
})->where('submenu', 0)->get();
If it belongs to Role model:
$menus = Menu::whereHas('roles', function($q)
{
$q->where('id', 4)->where('submenu', 0);
})->get();
Thank you for your reply Stolz!
I'm still having problems though :/ .. the following problem is displaying:
*Navigation is the term used instead of Menu
Column not found: 1054 Unknown column 'roles.navigation_id' in 'where clause' (SQL: select * from navigations
where (select count(*) from roles
where roles
.deleted_at
is null and roles
.navigation_id
= navigations
.id
and id
= 4 and roles
.deleted_at
is null) >= 1 and submenu
= 0)
The following are the tables and their fields
navigations Table-- id, name, url, order, submenu
roles Table-- id, name, desc
navigation_role Table (pivot table)-- id, navigation_id, role_id
OK! managed to solve the issue :)
Stolz your code was right, my problem was that instead of using belongsToMany I was using hasMany, when declaring many to many relationship inside my models
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community