<?php

declare(strict_types=1);

namespace App\Filament\Components\Form;

use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\Auth;

class FaqsRepeater extends Repeater
{
    public static function create(): static
    {
        return parent::make('faqs')
            ->label('سوالات متداول')
            ->relationship()
            ->schema([
                TextInput::make('question')
                    ->label('سوالات متداول'),
                TextInput::make('response')
                    ->label('سوالات متداول'),
                Hidden::make('created_by')
                    ->default(fn () => Auth::id()),
                Hidden::make('order')
                    ->default(0),
            ])
            ->collapsed()
            ->reorderable()
            ->orderColumn('order')
            ->itemLabel(fn (array $state): ?string => $state['question'] ?? null)
            ->columnSpan(12);
    }
}
