<?php
/*
    * Created by VahabDev in Aparat Live
    * Website: https://pourfi.ir
    * Aparat Live: https://www.aparat.com/vahabdev/live
    * Aparat Channel: https://www.aparat.com/vahabdev
    * Rubika Channel: https://rubika.ir/vahabdev
    * Donate: https://reymit.ir/vahabdev
    * Telegram: https://t.me/vahabdev
*/


namespace App\Filament\Resources\Pages\Schemas;

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class PageForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make('اطلاعات صفحه')
                    ->schema([
                        TextInput::make('name')
                            ->required()
                            ->maxLength(255)
                            ->label('نام صفحه')
                            ->live(onBlur: true),

                        TextInput::make('slug')
                            ->required()
                            ->maxLength(255)
                            ->unique(ignoreRecord: true)
                            ->label('اسلاگ'),

                        RichEditor::make('content')
                            ->required()
                            ->label('محتوا')
                            ->columnSpanFull(),

                        ToggleButtons::make('status')
                            ->label('وضعیت')
                            ->options([
                                'draft' => 'پیش‌نویس',
                                'published' => 'منتشر شده',
                            ])
                            ->colors([
                                'draft' => 'warning',
                                'published' => 'success',
                            ])
                            ->default('published')
                            ->inline()
                            ->required(),


                        Section::make('تنظیمات سئو')
                            ->schema([
                                TextInput::make('seo_title')
                                    ->label('عنوان سئو')
                                    ->maxLength(255),

                                Textarea::make('seo_description')
                                    ->label('توضیحات متا سئو')
                                    ->maxLength(500)
                                    ->rows(3),

                            ])
                            ->columnSpanFull()
                            ->columns(1),

                    ])
                    ->columns(2)
                    ->columnSpanFull(),

            ]);
    }
}
