|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Filament\Resources; |
| 4 | + |
| 5 | +use App\Filament\Resources\ActivityResource\Pages; |
| 6 | +use App\Filament\Resources\ActivityResource\RelationManagers; |
| 7 | +use App\Models\Activity; |
| 8 | +use Filament\Forms; |
| 9 | +use Filament\Resources\Form; |
| 10 | +use Filament\Resources\Resource; |
| 11 | +use Filament\Resources\Table; |
| 12 | +use Filament\Tables; |
| 13 | + |
| 14 | +class ActivityResource extends Resource |
| 15 | +{ |
| 16 | + protected static ?string $model = Activity::class; |
| 17 | + |
| 18 | + protected static ?string $navigationIcon = 'heroicon-o-clipboard'; |
| 19 | + |
| 20 | + protected static ?int $navigationSort = 1; |
| 21 | + |
| 22 | + protected static function getNavigationLabel(): string |
| 23 | + { |
| 24 | + return __('Activities'); |
| 25 | + } |
| 26 | + |
| 27 | + public static function getPluralLabel(): ?string |
| 28 | + { |
| 29 | + return static::getNavigationLabel(); |
| 30 | + } |
| 31 | + |
| 32 | + protected static function getNavigationGroup(): ?string |
| 33 | + { |
| 34 | + return __('Referential'); |
| 35 | + } |
| 36 | + |
| 37 | + public static function form(Form $form): Form |
| 38 | + { |
| 39 | + return $form |
| 40 | + ->schema([ |
| 41 | + Forms\Components\Card::make() |
| 42 | + ->schema([ |
| 43 | + Forms\Components\Grid::make() |
| 44 | + ->schema([ |
| 45 | + Forms\Components\TextInput::make('name') |
| 46 | + ->label(__('Activity name')) |
| 47 | + ->required() |
| 48 | + ->maxLength(255), |
| 49 | + |
| 50 | + Forms\Components\RichEditor::make('description') |
| 51 | + ->label(__('Description')) |
| 52 | + ->required() |
| 53 | + ->columnSpan(2), |
| 54 | + |
| 55 | + ]) |
| 56 | + ]) |
| 57 | + ]); |
| 58 | + } |
| 59 | + |
| 60 | + public static function table(Table $table): Table |
| 61 | + { |
| 62 | + return $table |
| 63 | + ->columns([ |
| 64 | + Tables\Columns\TextColumn::make('name') |
| 65 | + ->label(__('Activity name')) |
| 66 | + ->sortable() |
| 67 | + ->searchable(), |
| 68 | + |
| 69 | + Tables\Columns\TextColumn::make('created_at') |
| 70 | + ->label(__('Created at')) |
| 71 | + ->dateTime() |
| 72 | + ->sortable() |
| 73 | + ->searchable(), |
| 74 | + ]) |
| 75 | + ->filters([ |
| 76 | + // |
| 77 | + ]) |
| 78 | + ->actions([ |
| 79 | + Tables\Actions\ViewAction::make(), |
| 80 | + Tables\Actions\EditAction::make(), |
| 81 | + ]) |
| 82 | + ->bulkActions([ |
| 83 | + Tables\Actions\DeleteBulkAction::make(), |
| 84 | + ]) |
| 85 | + ->defaultSort('id'); |
| 86 | + } |
| 87 | + |
| 88 | + public static function getRelations(): array |
| 89 | + { |
| 90 | + return [ |
| 91 | + // |
| 92 | + ]; |
| 93 | + } |
| 94 | + |
| 95 | + public static function getPages(): array |
| 96 | + { |
| 97 | + return [ |
| 98 | + 'index' => Pages\ListActivities::route('/'), |
| 99 | + 'create' => Pages\CreateActivity::route('/create'), |
| 100 | + 'view' => Pages\ViewActivity::route('/{record}'), |
| 101 | + 'edit' => Pages\EditActivity::route('/{record}/edit'), |
| 102 | + ]; |
| 103 | + } |
| 104 | +} |
0 commit comments