<?php

namespace App\Http\Requests;

use App\Support\Tenancy;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class PublicBookingRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'dentist_id' => [
                'required',
                Rule::exists('dentists', 'id')
                    ->where('tenant_id', app(Tenancy::class)->id())
                    ->where('is_bookable_online', true)
                    ->where('status', 'active'),
            ],
            'starts_at' => ['required', 'date'],
            'full_name' => ['required', 'string', 'max:190'],
            'phone' => ['required', 'string', 'min:7', 'max:32'],
            'reason' => ['nullable', 'string', 'max:190'],
        ];
    }
}
