Home > Mobile >  Why does `getAllPermissions()` with where condition isn't working in Laravel?
Why does `getAllPermissions()` with where condition isn't working in Laravel?

Time:10-01

I am working in larael9 with spatie package to manage roles and permissions. I want to fetch user permissions with where condtion.

my permissions table is as following

id | name                           | guard_name    | created_at          | updated_at
-------------------------------------------------------------------------------------------------
14 | admin_side_barmenu_dashboard   | web           | 2022-09-29 13:52:00 | 2022-09-29 13:52:00
    
15 | admin_side_barmenu_users       | web           | 2022-09-29 13:52:00 | 2022-09-29 13:52:00
    
16 | admin_side_barmenu_settings    | web           | 2022-09-29 13:52:00 | 2022-09-29 13:52:00
    
17 | admin_side_barmenu_roles       | web           | 2022-09-29 13:52:00 | 2022-09-29 13:52:00
    
18 | admin_side_barmenu_permission  | web           | 2022-09-29 13:52:00 | 2022-09-29 13:52:00

what i am trying to achieve is, get permissions were name start with 'admin_side_barmenu' for auth user I am able to get all the permissions but not able to get where it start with 'admin_side_barmenu'.

I have tried the following way.

auth()->user()->getAllPermissions()->where('name', 'like', '           
  • Related