From ab249344543bdd68210c24541195450b0022e4a3 Mon Sep 17 00:00:00 2001 From: Ihab Abou Afia Date: Fri, 10 May 2024 06:55:29 -0400 Subject: [PATCH] o need to create a Roles and Permission classes in the application --- CHANGELOG.md | 4 +++ README.md | 28 +------------------ composer.json | 4 ++- .../components/livewire-layout.blade.php | 1 + .../livewire/permission-component.blade.php | 14 ++++++++-- .../views/livewire/role-component.blade.php | 16 +++++++++-- .../views/livewire/user-component.blade.php | 16 +++++++++-- src/Livewire/PermissionComponent.php | 4 +-- src/Livewire/RoleComponent.php | 4 +-- src/Livewire/UserComponent.php | 4 +-- src/Models/Permission.php | 11 ++++++++ src/Models/Role.php | 13 +++++++++ 12 files changed, 77 insertions(+), 42 deletions(-) create mode 100644 src/Models/Permission.php create mode 100644 src/Models/Role.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 916c394..4382fc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `permissions-admin` will be documented in this file. +## 1.0.3 - 2024-05-10 +- No need to create a Roles and Permission classes in the application. +- Minor bug fixes. + ## 1.0.2 - 2024-05-08 - Fixes the UserComponent modal and the form. - Added the option to disable eding the User Name, especially if are using the User model as first_name, last_name instead of name. diff --git a/README.md b/README.md index c5be629..d2c6496 100644 --- a/README.md +++ b/README.md @@ -33,33 +33,7 @@ composer require spatie/laravel-permission ```bash composer require livewire/livewire ``` -3. You need to create and empty ```App\Models\Role``` and ```App\Models\Permission``` class and add ```HasPermissionAdmin``` trait as follows: -```php -namespace App\Models; - -use IhabAfia\PermissionsAdmin\Traits\HasPermissionAdmin; -use Spatie\Permission\Models\Role as SpatieRole; - -class Role extends SpatieRole -{ - use HasPermissionAdmin; -} - -```` -```php -namespace App\Models; - -use IhabAfia\PermissionsAdmin\Traits\HasPermissionAdmin; -use Spatie\Permission\Models\Permission as SpatiePermission; - -class Permission extends SpatiePermission -{ - use HasPermissionAdmin; -} -```` -**These classes will not affect your application since these classes extends the original class.** - -4. You need to add ```HasPermissionAdmin``` trait in your ```User::class``` like follows: +3. You need to add ```HasPermissionAdmin``` trait in your ```User::class``` like follows: ```php namespace App\Models; diff --git a/composer.json b/composer.json index 83f87b6..a13a184 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,13 @@ "require": { "php": "^8.2", "illuminate/contracts": "^10.0||^11.0", - "livewire/livewire": "*", "spatie/laravel-package-tools": "^1.16" }, "require-dev": { "larastan/larastan": "^2.9", + "laravel/laravel": "^11.0", "laravel/pint": "^1.14", + "livewire/livewire": "*", "nunomaduro/collision": "^8.1.1||^7.10.0", "orchestra/testbench": "^9.0.0||^8.22.0", "pestphp/pest": "^2.34", @@ -32,6 +33,7 @@ "phpstan/extension-installer": "^1.3", "phpstan/phpstan-deprecation-rules": "^1.1", "phpstan/phpstan-phpunit": "^1.3", + "spatie/laravel-permission": "^6.7", "spatie/laravel-ray": "^1.35" }, "autoload": { diff --git a/resources/views/components/livewire-layout.blade.php b/resources/views/components/livewire-layout.blade.php index 8e80592..fb1d7a8 100644 --- a/resources/views/components/livewire-layout.blade.php +++ b/resources/views/components/livewire-layout.blade.php @@ -62,5 +62,6 @@ +@stack('scripts') diff --git a/resources/views/livewire/permission-component.blade.php b/resources/views/livewire/permission-component.blade.php index ea0a5db..c9f1fef 100644 --- a/resources/views/livewire/permission-component.blade.php +++ b/resources/views/livewire/permission-component.blade.php @@ -22,10 +22,13 @@ + placeholder="Search" + >
@@ -160,3 +163,10 @@ class="h-4 w-4 rounded border-gray-300 text-teal-600 focus:ring-teal-600"
+@push('scripts') + +@endpush diff --git a/resources/views/livewire/role-component.blade.php b/resources/views/livewire/role-component.blade.php index 22a6613..a2472c5 100644 --- a/resources/views/livewire/role-component.blade.php +++ b/resources/views/livewire/role-component.blade.php @@ -22,13 +22,16 @@ + placeholder="Search" + > -
+
+ placeholder="Search" + >