<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreSharedSubscriptionRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return auth()->check();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'service_id' => ['required', 'exists:services,id'],
            'service_plan_id' => ['required', 'exists:service_plans,id'],
            'title' => ['nullable', 'string', 'max:255'],
            'total_slots' => ['required', 'integer', 'min:1'],
            'available_slots' => ['required', 'integer', 'min:1', 'lte:total_slots'],
            'total_price' => ['required', 'numeric', 'min:0'],
            'price_per_slot' => ['required', 'numeric', 'min:0'],
            'is_public' => ['nullable', 'boolean'],
            'requires_manual_approval' => ['nullable', 'boolean'],
            'status' => ['nullable', 'in:draft,active,paused,full,cancelled,expired'],
            'notes' => ['nullable', 'string'],
            'starts_at' => ['nullable', 'date'],
            'ends_at' => ['nullable', 'date', 'after_or_equal:starts_at'],
        ];
    }
}
