laraditz/permission-plus

Laravel permission management for the lazy.

0.0.1 2023-02-24 07:49 UTC

This package is auto-updated.

Last update: 2024-11-26 07:46:33 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

Laravel permission management for the lazy. The permission plus is a RRBAC (Role/Route Based Access Control) which is a method to restrict access control based on the application routes and roles. (Warning: This package is still in an early stage of development and may contain bugs).

screenshot

Prerequisites

  • PHP 8.0+
  • Laravel v8.0+
  • Spatie Laravel Permission V5

Installation

You can install the package via composer:

composer require laraditz/permission-plus

If you don't have one, you may create a new user account to be able to access the permission plus page. Use Laravel starter kits to get ur application up and running in no time.

Setup

Run the migration command to create the necessary database table.

php artisan migrate

Add HasPermissionPlus trait to your User model.

use Laraditz\PermissionPlus\Traits\HasPermissionPlus;

class User extends Authenticatable
{
    use HasPermissionPlus;
}

(Optional) You can publish the config file via this command:

php artisan vendor:publish --provider="Laraditz\PermissionPlus\PermissionPlusServiceProvider" --tag="config"

Usage

After login, go to /permission-plus/permissions to manage your permission and you will see below page. You may click Generate button to generate all routes in your applications to start adding permissions.

screenshot 1

Repeat the step if you add more routes.

Deploy to production

By default, all App\Models\Users can access Permission Page locally. To allow them to access Permission Page in production, you must take a few extra steps to ensure that only the correct users have access to the page.

To set up your App\Models\User to access Permission Page in non-local environments, you must overwrite the canAccessPermissionPlus method.

public function canAccessPermissionPlus(): bool
{
    // example
    return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}

To Do

  • Add search
  • Add documentation
  • Add test
  • Permission for resource owner
  • Auto-detect available routes
  • Make a more user-friendly UI
  • Optimize layout for mobile view
  • Add permission for individual user
  • Refactor code

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email raditzfarhan@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.