finished the upgrade to filament 4. completely revamped the frontend with codex, now it looks great!

This commit is contained in:
2025-11-13 17:41:56 +01:00
parent 33d374304e
commit f59fda588b
23 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource\RelationManagers;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\Select;
class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $navigationGroup = 'User Management';
protected static ?string $navigationLabel = 'User Roles';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('User Details')
->schema([
TextInput::make('name')
->label(__('filament.resource.user.form.name'))
->required()
->maxLength(255),
TextInput::make('email')
->label(__('filament.resource.user.form.email'))
->email()
->required()
->maxLength(255),
TextInput::make('password')
->label(__('filament.resource.user.form.password'))
->password()
->dehydrateStateUsing(fn (string $state): string => bcrypt($state))
->dehydrated(fn (?string $state): bool => filled($state))
->required(fn (string $operation): bool => $operation === 'create')
->maxLength(255),
Select::make('role_id')
->relationship('role', 'name')
->label(__('filament.resource.user.form.role'))
->required(),
])->columns(2),
Forms\Components\Section::make('Preferences')
->schema([
Forms\Components\Toggle::make('email_notifications_enabled')
->label(__('Email Notifications'))
->default(true),
Select::make('theme_preference')
->label(__('Theme'))
->options([
'light' => 'Light',
'dark' => 'Dark',
])
->default('light'),
Select::make('locale')
->label(__('Language'))
->options([
'en' => 'English',
'de' => 'Deutsch',
])
->default('en'),
])->columns(2),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')->label(__('filament.resource.user.table.name'))->searchable()->sortable(),
TextColumn::make('email')->label(__('filament.resource.user.table.email'))->searchable()->sortable(),
TextColumn::make('role.name')->label(__('filament.resource.user.table.role'))->searchable()->sortable(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->emptyStateActions([
Tables\Actions\CreateAction::make(),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'edit' => Pages\EditUser::route('/{record}/edit'),
];
}
public static function getNavigationGroup(): ?string
{
return __('filament.navigation.groups.user_management');
}
public static function getNavigationLabel(): string
{
return __('filament.navigation.user_roles');
}
}