columns('full') ->schema([ Forms\Components\Tabs::make('Style Details') ->tabs([ Forms\Components\Tabs\Tab::make('General') ->schema([ Forms\Components\Grid::make(2) ->schema([ TextInput::make('title') ->label(__('filament.resource.style.form.title')) ->required() ->maxLength(255), Toggle::make('enabled') ->label(__('filament.resource.style.form.enabled')) ->default(true), ]), Forms\Components\Grid::make(2) ->schema([ Textarea::make('prompt') ->label(__('filament.resource.style.form.prompt')) ->required() ->rows(5), Textarea::make('description') ->label(__('filament.resource.style.form.description')) ->required() ->rows(5), ]), Select::make('ai_model_id') ->relationship('aiModel', 'name') ->label(__('filament.resource.style.form.ai_model')) ->required(), FileUpload::make('preview_image') ->label(__('filament.resource.style.form.preview_image')) ->disk('public') ->directory('style_previews') ->image() ->imageEditor() ->required() ->rules(['mimes:jpeg,png,bmp,gif,webp']), ]), Forms\Components\Tabs\Tab::make('Details') ->schema([ Forms\Components\TextInput::make('sort_order') ->numeric() ->default(0) ->label(__('filament.resource.style.form.sort_order')), Textarea::make('parameters') ->label(__('filament.resource.style.form.parameters')) ->nullable() ->rows(15) ->json() ->helperText(__('filament.resource.style.form.parameters_help')) ->formatStateUsing(fn (?array $state): ?string => $state ? json_encode($state, JSON_PRETTY_PRINT) : null), ]), ]), ]); } public static function table(Table $table): Table { return $table ->defaultSort('sort_order') ->reorderable('sort_order') ->columns([ TextColumn::make('title')->label(__('filament.resource.style.table.title'))->searchable()->sortable(), IconColumn::make('enabled') ->label(__('filament.resource.style.table.enabled')) ->boolean(), TextColumn::make('aiModel.name')->label(__('filament.resource.style.table.ai_model'))->searchable()->sortable(), ImageColumn::make('preview_image')->label(__('filament.resource.style.table.preview_image'))->disk('public'), TextColumn::make('sort_order')->label(__('filament.resource.style.table.sort_order'))->sortable(), ]) ->filters([ SelectFilter::make('ai_model') ->relationship('aiModel', 'name') ->label(__('filament.resource.style.table.ai_model')), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\Action::make('duplicate') ->label(__('filament.resource.style.action.duplicate')) ->icon('heroicon-o-document-duplicate') ->action(function (\App\Models\Style $record) { $newStyle = $record->replicate(); $newStyle->title = $record->title . ' (Kopie)'; $newStyle->save(); return redirect()->to(StyleResource::getUrl('edit', ['record' => $newStyle->id])); }), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), Tables\Actions\BulkAction::make('enable') ->label(__('filament.resource.style.action.enable_selected')) ->icon('heroicon-o-check-circle') ->action(function (\Illuminate\Support\Collection $records) { $records->each->update(['enabled' => true]); }), Tables\Actions\BulkAction::make('disable') ->label(__('filament.resource.style.action.disable_selected')) ->icon('heroicon-o-x-circle') ->action(function (\Illuminate\Support\Collection $records) { $records->each->update(['enabled' => false]); }), ]), ]) ->emptyStateActions([ Tables\Actions\CreateAction::make(), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListStyles::route('/'), 'create' => Pages\CreateStyle::route('/create'), 'edit' => Pages\EditStyle::route('/{record}/edit'), ]; } }