cdebattista / laravel-permission
Groups & Permissions for Laravel Jetstream
Requires
- php: ^7.3
- doctrine/dbal: ^2.11
- illuminate/support: ^8.0
Requires (Dev)
- inertiajs/inertia-laravel: ^0.2.15
- laravel/jetstream: ^1.4
- orchestra/testbench: ^6.2
- phpunit/phpunit: ^9.4
- tightenco/ziggy: ^0.9.4
This package is auto-updated.
Last update: 2024-11-15 03:24:54 UTC
README
⭐ Star on GitHub — it helps!
Table of content
Installation
Composer
composer require cdebattista/laravel-permission
Inertia
For now, support only Jetstream with Inertia.
In local installation and using
php artisan serve
, changeAPP_URL=http://127.0.0.1:8000
in .env. Otherwise, you will get an error:Access to XMLHttpRequest at 'http://localhost/users' from origin 'http://127.0.0.1:8000
php artisan permission:install inertia
npm install && npm run dev
php artisan migrate
How it works
Inertia
You can customize Actions, Models, Policies and Pages as your wishes.
PHP
In php code :
$user->hasPermissions(['view_user', 'view_group', 'view_permission']);
Protect your routes :
Route::group(['permissions' => ['administrator', 'create_user', 'view_user', 'edit_user', 'delete_user']], function (){ Route::resource('users', Inertia\UserController::class)->except(['show']); });
Vuejs
in VUE files :
this.HasPermissions(['view_user', 'view_group', 'view_permission'])
You can use directive v-can :
<div v-can="['view_user', 'view_group', 'view_permission']">...</div>
License
Laravel Permission is open-sourced software licensed under the MIT license.