Skip to content

Filter on Menu not working #307

@mtkumar82

Description

@mtkumar82

Hi,
I want to show menus based on User permissions and Roles in my application, I use Filter function there as per the documentation suggesting

->filter(function($item){
if(User::get()->can( $item->data('permission'))) {
return true;
}
return false;
});

$navbars->get('amazon_repricer')->add('Items', 'items', ['action' => 'AmazonRepricerItems@index'])->prepend('')->filter(function($item){
if(User::get()->can( $item->data('permission'))) {
return true;
}
return false;
});

But its not working for me and giving error "Call to undefined method Lavary\Menu\Item::filter()"

Please suggest a solution how it will work for me?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions