Add user management features to Citrus Platform: Integrated Filament Shield and Filament Users for role and permission management. Updated User model to include role functionality, added policies for Blog, Customer, Page, and Role management, and created necessary localization files for user management in multiple languages. Enhanced composer dependencies for improved functionality.
This commit is contained in:
+2
-1
@@ -6,11 +6,12 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
use HasFactory, Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use App\Models\Blog;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class BlogPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Blog');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Blog $blog): bool
|
||||
{
|
||||
return $authUser->can('View:Blog');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Blog');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Blog $blog): bool
|
||||
{
|
||||
return $authUser->can('Update:Blog');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Blog $blog): bool
|
||||
{
|
||||
return $authUser->can('Delete:Blog');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Blog $blog): bool
|
||||
{
|
||||
return $authUser->can('Restore:Blog');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Blog $blog): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Blog');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Blog');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Blog');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Blog $blog): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Blog');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Blog');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class CustomerPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Customer');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('View:Customer');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Customer');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Update:Customer');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Delete:Customer');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Restore:Customer');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Customer');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Customer');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Customer');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Customer $customer): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Customer');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Customer');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use App\Models\Page;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class PagePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Page');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Page $page): bool
|
||||
{
|
||||
return $authUser->can('View:Page');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Page');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Page $page): bool
|
||||
{
|
||||
return $authUser->can('Update:Page');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Page $page): bool
|
||||
{
|
||||
return $authUser->can('Delete:Page');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Page $page): bool
|
||||
{
|
||||
return $authUser->can('Restore:Page');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Page $page): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Page');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Page');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Page');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Page $page): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Page');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Page');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class RolePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Role');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('View:Role');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Role');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Update:Role');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Delete:Role');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Restore:Role');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Role');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Role');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Role');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Role');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Role');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,8 @@ use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Filament\Widgets\FilamentInfoWidget;
|
||||
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||
use TomatoPHP\FilamentUsers\FilamentUsersPlugin;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
@@ -38,6 +40,10 @@ class AdminPanelProvider extends PanelProvider
|
||||
Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Admin/Widgets'), for: 'App\Filament\Admin\Widgets')
|
||||
->plugins([
|
||||
FilamentShieldPlugin::make(),
|
||||
FilamentUsersPlugin::make(),
|
||||
])
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
FilamentInfoWidget::class,
|
||||
|
||||
Reference in New Issue
Block a user