-
Notifications
You must be signed in to change notification settings - Fork 10
Filament v4 #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Filament v4 #113
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
faf63e0
Run upgrade script
SebKay 712925f
Use v4 directory structure
SebKay 9efcf36
Remove upgrade script
SebKay d88d769
Update laravel-boost.mdc
SebKay bbc9795
Move form and table back into methods
SebKay 3c868e3
Use new form and table files
SebKay 2fce5b6
Add "All" table pagination option
SebKay 6348e2c
Update User.php
SebKay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...sources/UserResource/Pages/CreateUser.php → ...ment/Resources/Users/Pages/CreateUser.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Resources\Users\Schemas; | ||
|
|
||
| use Filament\Forms\Components\DateTimePicker; | ||
| use Filament\Forms\Components\Select; | ||
| use Filament\Forms\Components\TextInput; | ||
| use Filament\Schemas\Schema; | ||
|
|
||
| class UserForm | ||
| { | ||
| public static function configure(Schema $schema): Schema | ||
| { | ||
| return $schema | ||
| ->components([ | ||
| TextInput::make('first_name') | ||
| ->autofocus() | ||
| ->required() | ||
| ->maxLength(255), | ||
|
|
||
| TextInput::make('last_name') | ||
| ->required() | ||
| ->maxLength(255), | ||
|
|
||
| TextInput::make('email') | ||
| ->required() | ||
| ->email() | ||
| ->maxLength(255), | ||
|
|
||
| TextInput::make('password') | ||
| ->required(fn (string $operation): bool => $operation === 'create') | ||
| ->password() | ||
| ->afterStateHydrated(function (TextInput $component, $state) { | ||
| $component->state(''); | ||
| }) | ||
| ->dehydrated(fn (?string $state): bool => filled($state)) | ||
| ->maxLength(255), | ||
|
|
||
| DateTimePicker::make('email_verified_at'), | ||
|
|
||
| Select::make('roles') | ||
| ->preload() | ||
| ->multiple() | ||
| ->relationship('roles', 'name'), | ||
| ]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Resources\Users\Tables; | ||
|
|
||
| use Filament\Actions\BulkActionGroup; | ||
| use Filament\Actions\DeleteBulkAction; | ||
| use Filament\Actions\EditAction; | ||
| use Filament\Tables\Columns\IconColumn; | ||
| use Filament\Tables\Columns\TextColumn; | ||
| use Filament\Tables\Table; | ||
|
|
||
| class UsersTable | ||
| { | ||
| public static function configure(Table $table): Table | ||
| { | ||
| return $table | ||
| ->columns([ | ||
| TextColumn::make('name') | ||
| ->getStateUsing(fn ($record) => $record->fullName) | ||
| ->searchable() | ||
| ->sortable(), | ||
|
|
||
| TextColumn::make('email') | ||
| ->searchable() | ||
| ->sortable(), | ||
|
|
||
| IconColumn::make('email_verified') | ||
| ->getStateUsing(fn ($record) => $record->email_verified_at) | ||
| ->boolean() | ||
| ->sortable(), | ||
|
|
||
| TextColumn::make('roles') | ||
| ->getStateUsing(fn ($record) => $record->roles->pluck('name')->join(', ')) | ||
| ->searchable() | ||
| ->sortable(), | ||
|
|
||
| TextColumn::make('created_at') | ||
| ->dateTime() | ||
| ->sortable() | ||
| ->toggleable(isToggledHiddenByDefault: true), | ||
|
|
||
| TextColumn::make('updated_at') | ||
| ->dateTime() | ||
| ->sortable() | ||
| ->toggleable(isToggledHiddenByDefault: true), | ||
| ]) | ||
| ->recordActions([ | ||
| EditAction::make(), | ||
| ]) | ||
| ->toolbarActions([ | ||
| BulkActionGroup::make([ | ||
| DeleteBulkAction::make(), | ||
| ]), | ||
| ]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Resources\Users; | ||
|
|
||
| use App\Filament\Resources\Users\Pages\CreateUser; | ||
| use App\Filament\Resources\Users\Pages\EditUser; | ||
| use App\Filament\Resources\Users\Pages\ListUsers; | ||
| use App\Filament\Resources\Users\Schemas\UserForm; | ||
| use App\Filament\Resources\Users\Tables\UsersTable; | ||
| use App\Models\User; | ||
| use Filament\Resources\Resource; | ||
| use Filament\Schemas\Schema; | ||
| use Filament\Tables\Table; | ||
|
|
||
| class UserResource extends Resource | ||
| { | ||
| protected static ?string $model = User::class; | ||
|
|
||
| protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-users'; | ||
|
|
||
| protected static ?string $recordTitleAttribute = 'full_name'; | ||
|
|
||
| public static function form(Schema $schema): Schema | ||
| { | ||
| return UserForm::configure($schema); | ||
| } | ||
|
|
||
| public static function table(Table $table): Table | ||
| { | ||
| return UsersTable::configure($table); | ||
| } | ||
|
|
||
| public static function getPages(): array | ||
| { | ||
| return [ | ||
| 'index' => ListUsers::route('/'), | ||
| 'create' => CreateUser::route('/create'), | ||
| 'edit' => EditUser::route('/{record}/edit'), | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.