From efc45ea5a1d1a5b86bb104956368dc3e6e981638 Mon Sep 17 00:00:00 2001 From: Tim Van Dijck Date: Fri, 1 Mar 2024 17:03:58 +0100 Subject: [PATCH] Add filament user resource. --- app/Filament/Resources/UserResource.php | 103 ++++++++++++++++++ .../UserResource/Pages/CreateUser.php | 12 ++ .../Resources/UserResource/Pages/EditUser.php | 19 ++++ .../UserResource/Pages/ListUsers.php | 19 ++++ 4 files changed, 153 insertions(+) create mode 100644 app/Filament/Resources/UserResource.php create mode 100644 app/Filament/Resources/UserResource/Pages/CreateUser.php create mode 100644 app/Filament/Resources/UserResource/Pages/EditUser.php create mode 100644 app/Filament/Resources/UserResource/Pages/ListUsers.php diff --git a/app/Filament/Resources/UserResource.php b/app/Filament/Resources/UserResource.php new file mode 100644 index 00000000..182a333a --- /dev/null +++ b/app/Filament/Resources/UserResource.php @@ -0,0 +1,103 @@ +schema([ + Forms\Components\TextInput::make('uuid') + ->label('UUID') + ->maxLength(36), + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + Forms\Components\TextInput::make('email') + ->email() + ->required() + ->maxLength(255), + Forms\Components\TextInput::make('password') + ->password() + ->required() + ->maxLength(60), + Forms\Components\TextInput::make('github_id') + ->numeric(), + Forms\Components\TextInput::make('github_username') + ->maxLength(255), + Forms\Components\Toggle::make('is_sponsor'), + Forms\Components\TextInput::make('avatar') + ->maxLength(255), + Forms\Components\Toggle::make('is_admin') + ->required(), + Forms\Components\DateTimePicker::make('next_purchase_discount_period_ends_at'), + Forms\Components\DateTimePicker::make('sponsor_gift_given_at'), + Forms\Components\Toggle::make('has_access_to_unreleased_products') + ->required(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('avatar') + ->searchable(), + Tables\Columns\TextColumn::make('name') + ->searchable(), + Tables\Columns\TextColumn::make('email') + ->searchable(), + Tables\Columns\CheckboxColumn::make('is_sponsor'), + Tables\Columns\CheckboxColumn::make('is_admin'), + Tables\Columns\CheckboxColumn::make('has_access_to_unreleased_products'), + + Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::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'), + ]; + } +} diff --git a/app/Filament/Resources/UserResource/Pages/CreateUser.php b/app/Filament/Resources/UserResource/Pages/CreateUser.php new file mode 100644 index 00000000..73aa46d0 --- /dev/null +++ b/app/Filament/Resources/UserResource/Pages/CreateUser.php @@ -0,0 +1,12 @@ +