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

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