Skip to content

Commit 4b97721

Browse files
committed
2 parents bf8e9af + a4c7ad1 commit 4b97721

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ composer require obrainwave/access-tree
1414
You can publish and run the migrations with:
1515

1616
```bash
17-
php artisan vendor:publish --tag=":access-tree-migrations"
17+
php artisan vendor:publish --tag="accesstree-migrations"
1818
php artisan migrate
1919
```
2020

21+
Create a Root User:
22+
23+
After running migration, a new column `is_root_user` will be added to the `users` table. To create a user that can override all permissions and roles in your application, set the column to be `true` for the particular user.
24+
2125
You can publish the config file with:
2226

2327
```bash
24-
php artisan vendor:publish --tag="access-tree-config"
28+
php artisan vendor:publish --tag="accesstree-config"
2529
```
2630

2731
## Usage
@@ -78,6 +82,32 @@ $user_role = createUserRole($roles, $user_id);
7882
echo $user_role;
7983
```
8084

85+
Update User Role
86+
```php
87+
$roles = array of roles from Obrainwave\AccessTree\Models\Role // array(2, 5);
88+
$user_id = id of a user from App\Models\User // 5;
89+
$user_role = updateUserRole($roles, $user_id);
90+
echo $user_role;
91+
```
92+
93+
Check User Access or Permission
94+
```php
95+
checkPermission(string slug_of_permission) // returns true or false
96+
```
97+
Call the above function anywhere in your application. Example of usage:
98+
```php
99+
@if(checkPermission('add_user')
100+
// Do some stuff
101+
@else
102+
throw new \Exception("Access Forbidden", 1);
103+
@endif
104+
```
105+
106+
Check if a User is a Root User
107+
```php
108+
isRootUser(int user_id) // returns true or false
109+
```
110+
81111
## Changelog
82112

83113
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

0 commit comments

Comments
 (0)