From c91976b4e9a9446632faf9a4ae71a41bee6afd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Sat, 27 Sep 2025 14:29:58 -0300 Subject: [PATCH] =?UTF-8?q?Refactor=20PageForm=20schema=20in=20Filament=20?= =?UTF-8?q?admin=20panel:=20Restructured=20form=20layout=20into=20sections?= =?UTF-8?q?=20for=20better=20organization,=20including=20'=C4=B0=C3=A7erik?= =?UTF-8?q?',=20'Sayfa=20Ayarlar=C4=B1',=20and=20'SEO=20Ayarlar=C4=B1'.=20?= =?UTF-8?q?Updated=20components=20to=20enhance=20user=20experience=20and?= =?UTF-8?q?=20maintainability.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/Pages/Schemas/PageForm.php | 246 ++++++++++-------- 1 file changed, 140 insertions(+), 106 deletions(-) diff --git a/app/Filament/Admin/Resources/Pages/Schemas/PageForm.php b/app/Filament/Admin/Resources/Pages/Schemas/PageForm.php index 7e03960..f71e9d9 100644 --- a/app/Filament/Admin/Resources/Pages/Schemas/PageForm.php +++ b/app/Filament/Admin/Resources/Pages/Schemas/PageForm.php @@ -7,6 +7,7 @@ use Filament\Forms\Components\DateTimePicker; use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\Hidden; use Filament\Forms\Components\RichEditor; +use Filament\Schemas\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; @@ -17,117 +18,150 @@ class PageForm public static function configure(Schema $schema): Schema { return $schema - ->components([ - TextInput::make('title') - ->label('Başlık') - ->required() - ->maxLength(255) - ->live(onBlur: true) - ->afterStateUpdated(function (string $operation, $state, callable $set) { - if ($operation !== 'create') { - return; - } - $set('slug', \Str::slug($state)); - }), - - TextInput::make('slug') - ->label('URL Slug') - ->required() - ->maxLength(255) - ->unique(ignoreRecord: true) - ->rules(['alpha_dash']) - ->helperText('URL\'de görünecek kısım. Örnek: hakkimizda'), - - Textarea::make('excerpt') - ->label('Özet') - ->rows(3) - ->maxLength(500) - ->helperText('Sayfa özeti (maksimum 500 karakter)'), - - RichEditor::make('content') - ->label('İçerik') - ->required() - ->fileAttachmentsDisk('public') - ->fileAttachmentsDirectory('pages') - ->fileAttachmentsVisibility('public'), - - Select::make('status') - ->label('Durum') - ->options([ - 'draft' => 'Taslak', - 'published' => 'Yayında', - 'archived' => 'Arşivlendi', + ->columns(3) + ->schema([ + // Sol kolon - Ana içerik (2 sütun genişliğinde) + Section::make('İçerik') + ->schema([ + TextInput::make('title') + ->label('Başlık') + ->required() + ->maxLength(255) + ->live(onBlur: true) + ->afterStateUpdated(function (string $operation, $state, callable $set) { + if ($operation !== 'create') { + return; + } + $set('slug', \Str::slug($state)); + }), + + TextInput::make('slug') + ->label('URL Slug') + ->required() + ->maxLength(255) + ->unique(ignoreRecord: true) + ->rules(['alpha_dash']) + ->helperText('URL\'de görünecek kısım. Örnek: hakkimizda'), + + RichEditor::make('content') + ->label('İçerik') + ->required() + ->fileAttachmentsDisk('public') + ->fileAttachmentsDirectory('pages') + ->fileAttachmentsVisibility('public') + ->columnSpanFull(), + + Textarea::make('excerpt') + ->label('Özet') + ->rows(3) + ->maxLength(500) + ->helperText('Sayfa özeti (maksimum 500 karakter)') + ->columnSpanFull(), ]) - ->default('draft') - ->required(), + ->columnSpan(2) + ->collapsible(false), - DateTimePicker::make('published_at') - ->label('Yayın Tarihi') - ->displayFormat('d.m.Y H:i') - ->helperText('Boş bırakılırsa şu anki tarih kullanılır'), - - Select::make('author_id') - ->label('Yazar') - ->relationship('author', 'name') - ->default(auth()->id()) - ->required(), - - Select::make('parent_id') - ->label('Üst Sayfa') - ->relationship('parent', 'title') - ->searchable() - ->preload() - ->helperText('Bu sayfayı başka bir sayfanın alt sayfası yapmak için seçin'), - - TextInput::make('sort_order') - ->label('Sıra') - ->numeric() - ->default(0) - ->helperText('Menüde görünme sırası'), - - Select::make('template') - ->label('Şablon') - ->options([ - 'default' => 'Varsayılan', - 'landing' => 'Landing Page', - 'blog' => 'Blog', - 'contact' => 'İletişim', + // Sağ kolon - Metadata ve öne çıkan görsel (1 sütun genişliğinde) + Section::make('Sayfa Ayarları') + ->schema([ + FileUpload::make('featured_image') + ->label('Öne Çıkan Görsel') + ->image() + ->disk('public') + ->directory('pages/featured') + ->visibility('public') + ->imageEditor() + ->imageEditorAspectRatios([ + '16:9', + '4:3', + '1:1', + ]) + ->helperText('Sayfa için öne çıkan görsel seçin') + ->columnSpanFull(), + + Select::make('author_id') + ->label('Yazar') + ->relationship('author', 'name') + ->default(auth()->id()) + ->required() + ->columnSpanFull(), + + DateTimePicker::make('published_at') + ->label('Yayın Tarihi') + ->displayFormat('d.m.Y H:i') + ->helperText('Boş bırakılırsa şu anki tarih kullanılır') + ->columnSpanFull(), + + Select::make('status') + ->label('Durum') + ->options([ + 'draft' => 'Taslak', + 'published' => 'Yayında', + 'archived' => 'Arşivlendi', + ]) + ->default('draft') + ->required() + ->columnSpanFull(), + + Select::make('parent_id') + ->label('Üst Sayfa') + ->relationship('parent', 'title') + ->searchable() + ->preload() + ->helperText('Bu sayfayı başka bir sayfanın alt sayfası yapmak için seçin') + ->columnSpanFull(), + + Select::make('template') + ->label('Şablon') + ->options([ + 'default' => 'Varsayılan', + 'landing' => 'Landing Page', + 'blog' => 'Blog', + 'contact' => 'İletişim', + ]) + ->default('default') + ->columnSpanFull(), + + TextInput::make('sort_order') + ->label('Sıra') + ->numeric() + ->default(0) + ->helperText('Menüde görünme sırası') + ->columnSpanFull(), + + Checkbox::make('is_homepage') + ->label('Ana Sayfa') + ->helperText('Bu sayfayı ana sayfa olarak ayarla') + ->columnSpanFull(), + + Checkbox::make('show_in_menu') + ->label('Menüde Göster') + ->default(true) + ->helperText('Bu sayfa menüde görünsün mü?') + ->columnSpanFull(), ]) - ->default('default'), + ->columnSpan(1) + ->collapsible(false), - Checkbox::make('is_homepage') - ->label('Ana Sayfa') - ->helperText('Bu sayfayı ana sayfa olarak ayarla'), - - Checkbox::make('show_in_menu') - ->label('Menüde Göster') - ->default(true) - ->helperText('Bu sayfa menüde görünsün mü?'), - - TextInput::make('meta_title') - ->label('Meta Başlık') - ->maxLength(60) - ->helperText('Arama motorları için başlık (maksimum 60 karakter)'), - - Textarea::make('meta_description') - ->label('Meta Açıklama') - ->rows(3) - ->maxLength(160) - ->helperText('Arama motorları için açıklama (maksimum 160 karakter)'), - - FileUpload::make('featured_image') - ->label('Öne Çıkan Görsel') - ->image() - ->disk('public') - ->directory('pages/featured') - ->visibility('public') - ->imageEditor() - ->imageEditorAspectRatios([ - '16:9', - '4:3', - '1:1', + // Alt kısım - SEO ayarları (tam genişlik) + Section::make('SEO Ayarları') + ->schema([ + TextInput::make('meta_title') + ->label('Meta Başlık') + ->maxLength(60) + ->helperText('Arama motorları için başlık (maksimum 60 karakter)'), + + Textarea::make('meta_description') + ->label('Meta Açıklama') + ->rows(3) + ->maxLength(160) + ->helperText('Arama motorları için açıklama (maksimum 160 karakter)') + ->columnSpanFull(), ]) - ->helperText('Sayfa için öne çıkan görsel seçin'), + ->columns(2) + ->columnSpanFull() + ->collapsible(true) + ->collapsed(true), ]); } }