<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StorePageRequest extends FormRequest
{
    public function authorize(): bool
    {
        return auth()->check();
    }

    public function rules(): array
    {
        return [
            'pagename' => [
                'required',
                'string',
                'max:200',
                Rule::unique('pagedetails', 'pagename')->where(fn ($query) => $query->where('createdby', auth()->id())),
            ],
            'pageorder' => ['nullable', 'integer', 'min:0', 'max:99'],
            'DSC' => ['nullable', 'string'],
            'photoid' => ['nullable', 'integer'],
        ];
    }
}
