schema([ Section::make() ->schema([ Forms\Components\Grid::make(2)->schema([ TextInput::make('title')->label('Заголовок')->required() ->live(onBlur: true) ->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) { $set('slug', Str::slug($state)); }), TextInput::make('slug')->label('Slug')->unique(ignoreRecord: true)->readOnly()->required(), ]), Section::make()->schema([ \Filament\Forms\Components\Builder::make('content')->label('Контент')->blocks([ Builder\Block::make('heading') ->schema([ TextInput::make('content') ->label('Heading') ->required(), Select::make('level') ->options([ 'h1' => 'Heading 1', 'h2' => 'Heading 2', 'h3' => 'Heading 3', 'h4' => 'Heading 4', 'h5' => 'Heading 5', 'h6' => 'Heading 6', ]) ->required(), ]) ->columns(2), Builder\Block::make('paragraph') ->schema([ RichEditor::make('content') ->label('Paragraph') ->required() ]), Builder\Block::make('image') ->schema([ FileUpload::make('url') ->label('Image') ->image() ->required(), TextInput::make('alt') ->label('Alt text') ->required(), ]), Builder\Block::make('video') ->schema([ Hidden::make('mime'), TextInput::make('title') ->required() ->maxLength(255) ->autofocus(), FileUpload::make('path') ->required() ->acceptedFileTypes(['video/mp4','video/ogg','video/webm']) ->maxSize(512000) ->disk('videos') ->visibility('public') ->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())), ]) ]), ]), Select::make('status')->options([ 'verification' => 'На рассмотрении', 'published' => 'Одобрено', 'rejected' => 'Отказано', ])->label('Статус')->required()->default('verification'), Forms\Components\TagsInput::make('authors') ->label('Авторы')->placeholder('Добавить автора'), SpatieTagsInput::make('tags') ->label('Тэги'), Select::make('category_id') ->options(Category::all()->pluck('title', 'id')) ->preload() ->label('Категория'), FileUpload::make('preview')->label('Превью новости')->image()->imageEditor(), TextInput::make('search_data')->hidden(), ]) ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('id'), Tables\Columns\TextColumn::make('title')->label('Заголовок') ->searchable(), Tables\Columns\TextColumn::make('status')->label('Статус')->badge() ])->defaultSort('created_at', 'desc') ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListRedactorPosts::route('/'), 'create' => Pages\CreateRedactorPost::route('/create'), 'edit' => Pages\EditRedactorPost::route('/{record}/edit'), ]; } }