Menu Roles and Roles

In the file MenuTablesSeeder you must enter a role for that dropdown and it’s links.

I have many Roles assigned to me, including Admin and Order Entry. When running the code below, I can’t see the menu item unless I add all the other roles I have been assigned. That defeats the purpose because someone in Order Entry will not be an Admin. Why won’t this work?

  $this->beginDropdown('order-entry', 'Order Entry', 'cil-folder-open');
    $this->insertLink('order-entry', 'Dashboard', '/dashboard/order-entry');
    $this->insertLink('order-entry', 'Customers', '/customers/?active=1');
    $this->insertLink('order-entry', 'Vendors', '/vendors');
    $this->insertLink('order-entry', 'Sales Orders', '/salesorders');

The algorithm I will describe now is in the file:


-the role belonging to the logged-in user with the highest hierarchy is found
-The found role is used to generate a menu

If user has ‘admin,other-entry’ roles
Where the role admin is higher in the hierarchy than the other-entry
And this is how the menu item insert:
$this->insertLink('order-entry', 'Customers', '/customers/?active=1');
It will cause the user not to see this menu item.
Because it will only see the menu items assigned to the admin role. (The highest in hierarchy)
For this user to see a menu item you have to do
one of three things:
-Change roles in their hierarchy
-Remove the ‘admin’ role from user
-Assign a menu item to the ‘admin,order-entry’ roles

I will look into that. Thank you so much!

I must be doing something wrong. With the code below, I can click on Sales Orders under Employee Links, but I get a 403.

Here is the code for the UsersSeeder:

    $user = User::create([
        'name' => 'AJ',
        'last_name' => 'Smith',
        'menuroles' => 'admin',
        'type' => 'Admin',

And the MenusTableSeeder:

    $this->insertLink('employee,order-entry,admin', 'Main Dashboard', '/home', 'cil-speedometer');

    $this->beginDropdown('admin,employee,order-entry', 'Employee Links', 'cil-folder-open');
    $this->insertLink('admin,employee,order-entry', 'Sales Orders', '/salesorders');
    $this->insertLink('admin,employee,order-entry', 'Phone List', '/phonelist');

    $this->beginDropdown('admin,order-entry', 'Order Entry', 'cil-folder-open');
    $this->insertLink('admin,order-entry', 'Dashboard', '/dashboard/order-entry');
    $this->insertLink('admin,order-entry', 'Customers', '/customers/?active=1');
    $this->insertLink('admin,order-entry', 'Vendors', '/vendors');
    $this->insertLink('admin,order-entry', 'Sales Orders', '/salesorders');

I think I have it figured out. Thanks for the help. It led me in the right direction.

After working on this for a few days, I’m still a bit confused. If I have users with 1 role (employee), I only want them to see certain links. However, some links should be available to multiple roles. I can’t seem to get this to work.

Is there a different way to do this?

I feel dumb. It was a problem with the Routes file.