|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Filament\Resources; |
| 4 | + |
| 5 | +use App\Filament\Resources\ResearchSpaceResource\Pages; |
| 6 | +use App\Models\ResearchSpace; |
| 7 | +use Filament\Schemas\Schema; |
| 8 | +use Filament\Schemas\Components\Section; |
| 9 | +use Filament\Schemas\Components\Grid; |
| 10 | +use Filament\Forms\Components\TextInput; |
| 11 | +use Filament\Forms\Components\Textarea; |
| 12 | +use Filament\Forms\Components\Toggle; |
| 13 | +use Filament\Tables\Table; |
| 14 | +use Filament\Tables\Columns\TextColumn; |
| 15 | +use Filament\Resources\Resource; |
| 16 | + |
| 17 | +class ResearchSpaceResource extends Resource |
| 18 | +{ |
| 19 | + protected static ?string $model = ResearchSpace::class; |
| 20 | + |
| 21 | + protected static ?string $navigationIcon = 'heroicon-o-users'; |
| 22 | + |
| 23 | + protected static ?string $navigationGroup = 'Collaboration'; |
| 24 | + |
| 25 | + protected static ?string $navigationLabel = 'Research Spaces'; |
| 26 | + |
| 27 | + public static function form(Schema $schema): Schema |
| 28 | + { |
| 29 | + return $schema |
| 30 | + ->components([ |
| 31 | + Section::make('Details') |
| 32 | + ->schema([ |
| 33 | + Grid::make(1) |
| 34 | + ->schema([ |
| 35 | + TextInput::make('name') |
| 36 | + ->required() |
| 37 | + ->maxLength(255), |
| 38 | + TextInput::make('slug') |
| 39 | + ->required() |
| 40 | + ->maxLength(255), |
| 41 | + Textarea::make('description') |
| 42 | + ->rows(4), |
| 43 | + Toggle::make('is_private') |
| 44 | + ->label('Private') |
| 45 | + ->default(true), |
| 46 | + ]), |
| 47 | + ]), |
| 48 | + ]); |
| 49 | + } |
| 50 | + |
| 51 | + public static function table(Table $table): Table |
| 52 | + { |
| 53 | + return $table |
| 54 | + ->columns([ |
| 55 | + TextColumn::make('id')->label('ID')->sortable(), |
| 56 | + TextColumn::make('name')->searchable()->sortable(), |
| 57 | + TextColumn::make('owner.name')->label('Owner')->sortable(), |
| 58 | + TextColumn::make('is_private')->boolean()->label('Private'), |
| 59 | + TextColumn::make('created_at')->label('Created')->dateTime(), |
| 60 | + ]); |
| 61 | + } |
| 62 | + |
| 63 | + public static function getPages(): array |
| 64 | + { |
| 65 | + return [ |
| 66 | + 'index' => Pages\ListResearchSpaces::route('/'), |
| 67 | + 'create' => Pages\CreateResearchSpace::route('/create'), |
| 68 | + 'edit' => Pages\EditResearchSpace::route('/{record}/edit'), |
| 69 | + ]; |
| 70 | + } |
| 71 | +} |
0 commit comments