ijodkor / guard
There is no license information available for the latest version (v0.0.2) of this package.
Role, permission and action access control
v0.0.2
2025-05-14 09:26 UTC
Requires
- php: ^8.0|^8.1|^8.2
- ijodkor/laravel-api-response: ^1.2|^1.3
- illuminate/contracts: ^v10.0.1|^v11.17.0|^v12.10
- illuminate/database: ^v9.10|^v10.10|^v11.17|^v12.10
- spatie/laravel-translatable: ^5.2|^6.0
- tymon/jwt-auth: ^2.0
Requires (Dev)
- phpunit/phpunit: ^10.0|^11.2.8
This package is not auto-updated.
Last update: 2025-06-12 08:06:53 UTC
README
Role access by level, position and type
Glossaries
- RBAC - role based access
- LBAC - level based access (republic, province, district > ...)
- ABAC\RABAC - (Restricted) Action based access
Installation and setup
The package will automatically register itself.
Publish migrations
php artisan vendor:publish --provider="Ijodkor\Guard\GuardServiceProvider" --tag="guard-migrations"
Adjust multischeme for project to service provider
AppServiceProvider ... /** * Bootstrap any application services. */ public function boot(): void { $main = database_path('migrations'); $directories = ['public', 'users', 'rbac']; $paths = []; foreach ($directories as $directory) { $paths[] = database_path('migrations' . DIRECTORY_SEPARATOR . $directory); } $paths = array_merge([$main], $paths); $this->loadMigrationsFrom($paths); }
And define search path of schemas to database.php
... 'pgsql' => [ 'driver' => 'pgsql', .... 'search_path' => SchemeList::schemas(), ], ...
Run migration
php artisan migrate
Add seeders to Database seeder in your project
class DatabaseSeeder extends Seeder { /** * Seed the application's database. */ public function run(): void { $this->call(UserSeeder::class); $this->call(RoleSeeder::class); } }
Run database seeder
php artisan db:seed
Customize models
Extend user from guard user
use Ijodkor\Guard\Models\User as GuardUser; class User extends GuardUser { } ...
References
Links
Remainder
Add extra middleware and use this to customize built-in middleware
Illuminate Foundation abandoned, so we change use Illuminate\Foundation\Auth\User as Authenticatable in UserModel