feat: granular permissions, export backup, user/role management
- PermissionSeeder: 29 permissions with role mapping (admin/manager/staff) - Policies updated to use hasPermissionTo() instead of hasRole() - ExportBackup command: JSON per-table backup with chunk processing - UserResource: CRUD users with role assignment (admin only) - RoleResource: CRUD roles with permission assignment (admin only) - UserPolicy + RolePolicy: admin-only access control - ImportCskh: detailed skip logging with color in dry-run mode - Widgets: permission-based visibility checks - Tests: 8/8 pass (21 assertions)
This commit is contained in:
42
app/Filament/Resources/Users/Schemas/UserForm.php
Normal file
42
app/Filament/Resources/Users/Schemas/UserForm.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
|
||||
TextInput::make('email')
|
||||
->email()
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->unique(ignoreRecord: true),
|
||||
|
||||
TextInput::make('password')
|
||||
->password()
|
||||
->revealable()
|
||||
->required(fn (string $operation): bool => $operation === 'create')
|
||||
->dehydrateStateUsing(fn (?string $state): ?string => filled($state) ? bcrypt($state) : null)
|
||||
->dehydrated(fn (?string $state): bool => filled($state))
|
||||
->maxLength(255)
|
||||
->columnSpanFull(),
|
||||
|
||||
Select::make('role')
|
||||
->label('Role')
|
||||
->options(Role::pluck('name', 'name')->toArray())
|
||||
->required()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user