|
4 | 4 |
|
5 | 5 | namespace App\Filament\Resources; |
6 | 6 |
|
7 | | -use App\Enums\VacationType; |
8 | 7 | use App\Filament\Resources\VacationResource\Pages; |
9 | | -use App\Forms\Components\Value; |
| 8 | +use App\Filament\Resources\VacationResource\Schemas\VacationForm; |
| 9 | +use App\Filament\Resources\VacationResource\Schemas\VacationInfolist; |
10 | 10 | use App\Models\County; |
11 | 11 | use App\Models\Vacation; |
12 | 12 | use App\Tables\Columns\TextColumn; |
13 | | -use Filament\Forms\Components\DatePicker; |
14 | | -use Filament\Forms\Components\Grid; |
15 | | -use Filament\Forms\Components\Select; |
16 | | -use Filament\Forms\Components\Textarea; |
17 | 13 | use Filament\Forms\Form; |
| 14 | +use Filament\Infolists\Infolist; |
18 | 15 | use Filament\Resources\Resource; |
19 | 16 | use Filament\Tables; |
20 | 17 | use Filament\Tables\Filters\SelectFilter; |
@@ -49,7 +46,13 @@ public static function getPluralModelLabel(): string |
49 | 46 | public static function form(Form $form): Form |
50 | 47 | { |
51 | 48 | return $form |
52 | | - ->schema(static::getEditFormSchema()); |
| 49 | + ->schema(VacationForm::getSchema()); |
| 50 | + } |
| 51 | + |
| 52 | + public static function infolist(Infolist $infolist): Infolist |
| 53 | + { |
| 54 | + return $infolist |
| 55 | + ->schema(VacationInfolist::getSchema()); |
53 | 56 | } |
54 | 57 |
|
55 | 58 | public static function table(Table $table): Table |
@@ -126,89 +129,21 @@ public static function table(Table $table): Table |
126 | 129 | ]) |
127 | 130 | ->actions([ |
128 | 131 | Tables\Actions\ViewAction::make() |
129 | | - ->form(static::getViewFormSchema()) |
130 | 132 | ->iconButton(), |
131 | 133 |
|
132 | 134 | Tables\Actions\EditAction::make() |
133 | | - ->form(static::getEditFormSchema()) |
134 | 135 | ->iconButton(), |
135 | 136 |
|
136 | 137 | Tables\Actions\DeleteAction::make() |
137 | 138 | ->iconButton(), |
138 | 139 | ]) |
139 | | - ->bulkActions([ |
140 | | - // |
141 | | - ]) |
142 | 140 | ->defaultSort('id', 'desc'); |
143 | 141 | } |
144 | 142 |
|
145 | | - public static function getRelations(): array |
146 | | - { |
147 | | - return [ |
148 | | - // |
149 | | - ]; |
150 | | - } |
151 | | - |
152 | 143 | public static function getPages(): array |
153 | 144 | { |
154 | 145 | return [ |
155 | 146 | 'index' => Pages\ManageVacations::route('/'), |
156 | 147 | ]; |
157 | 148 | } |
158 | | - |
159 | | - public static function getEditFormSchema(): array |
160 | | - { |
161 | | - return [ |
162 | | - Select::make('type') |
163 | | - ->label(__('field.type')) |
164 | | - ->options(VacationType::options()) |
165 | | - ->enum(VacationType::class) |
166 | | - ->required(), |
167 | | - |
168 | | - Grid::make() |
169 | | - ->schema([ |
170 | | - DatePicker::make('start_date') |
171 | | - ->label(__('field.start_date')) |
172 | | - ->required(), |
173 | | - |
174 | | - DatePicker::make('end_date') |
175 | | - ->label(__('field.end_date')) |
176 | | - ->afterOrEqual('start_date') |
177 | | - ->required(), |
178 | | - ]) |
179 | | - ->columnSpanFull(), |
180 | | - |
181 | | - Textarea::make('notes') |
182 | | - ->label(__('field.notes')) |
183 | | - ->autosize(false) |
184 | | - ->rows(4) |
185 | | - ->columnSpanFull() |
186 | | - ->extraInputAttributes([ |
187 | | - 'class' => 'resize-none', |
188 | | - ]) |
189 | | - ->columnSpanFull(), |
190 | | - ]; |
191 | | - } |
192 | | - |
193 | | - public static function getViewFormSchema(): array |
194 | | - { |
195 | | - return [ |
196 | | - Value::make('type') |
197 | | - ->label(__('field.type')), |
198 | | - |
199 | | - Grid::make() |
200 | | - ->schema([ |
201 | | - Value::make('start_date') |
202 | | - ->label(__('field.start_date')), |
203 | | - |
204 | | - Value::make('end_date') |
205 | | - ->label(__('field.end_date')), |
206 | | - ]) |
207 | | - ->columnSpanFull(), |
208 | | - |
209 | | - Value::make('notes') |
210 | | - ->label(__('field.notes')) |
211 | | - ->columnSpanFull(), |
212 | | - ]; |
213 | | - } |
214 | 149 | } |
0 commit comments