php - Laravel Spatie/Permission specific permission for each individual location/branch

one text

I am trying to provide user role/permission using spatie/laravel.

Currently, it's working without issues, but I need to specify the user permission for each branch/locations (sub_locations table) for single user.

e.g.,

user A can edit something on sub_location 1, but can't edit that from sub_location 2 login.

Same, user B has an admin role in 1 & 4 locations and non admin in all other locations.

So, I need to provide permissions/role based on sub_locations.

I am not sure how to do that.

I need to control user permissions in both controller and views.

Also, I have not yet changed any default functions of spatie/laravel and it's tables.

Below are the user table structure.

Users Table

user_id (UQ),
password,
status, ("Y"=> Active, "N"=> Inactive)
//other fields

User_Locations Table

id (PK, AI),
user_id (FK),
location_id (FK),
sub_location_id (FK),
status ("Y"=> Active, "N"=> Inactive)

Locations Table

id (PK, AI),
location_id,
location_name

Sub_Locations Table

id (PK, AI),
location_id (FK),
sub_location_id,
sub_location_name

Source