Skip to content
Discussion options

You must be logged in to vote

I have tried the following way.
auth()->user()->getAllPermissions()->where('name', 'like', '%admin_side_barmenu%')->toArray();

Because getAllPermissions() returns a collection, and collections don't use like, use filter with your own logic, like:

auth()->user()->getAllPermissions()
    ->filter( fn($p) => \Str::contains($p->name, 'admin_side_barmenu') )
    ->toArray();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by drbyte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants