<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'start_time' => ['required', 'date_format:H:i'],
            'end_time' => ['required', 'date_format:H:i'],
        ];
    }

    public function messages(): array
    {
        return [
            'name.required' => 'Nama Shift wajib diisi.',
            'start_time.required' => 'Jam masuk wajib diisi.',
            'start_time.date_format' => 'Format jam masuk harus HH:MM (contoh: 07:00).',
            'end_time.required' => 'Jam pulang wajib diisi.',
            'end_time.date_format' => 'Format jam pulang harus HH:MM (contoh: 15:30).',
        ];
    }
}
