<?php

namespace App\Http\Requests\Admin;

use App\Models\Shift;
use Illuminate\Foundation\Http\FormRequest;

class OpenShiftRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('create', Shift::class) ?? false;
    }

    /** @return array<string, mixed> */
    public function rules(): array
    {
        return [
            'opening_cash'            => ['required', 'numeric', 'min:0'],
            'notes'                   => ['nullable', 'string', 'max:1000'],
            // Denomination helper (Slice C) — counts per face value.
            'opening_denominations'   => ['nullable', 'array'],
            'opening_denominations.*' => ['nullable', 'integer', 'min:0'],
        ];
    }

    /** @return array<string, string> */
    public function attributes(): array
    {
        return [
            'opening_cash' => __('shifts.fields.opening_cash'),
            'notes'        => __('shifts.fields.notes'),
        ];
    }
}
