<?php

namespace App\Http\Requests\Staff;

use Illuminate\Foundation\Http\FormRequest;

class StoreStaffRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('manage staff') ?? false;
    }

    public function rules(): array
    {
        return [
            'first_name' => 'required|string|max:100',
            'last_name' => 'nullable|string|max:100',
            'mobile' => 'nullable|string|max:20',
            'email' => 'nullable|email|max:100',
            'gender' => 'nullable|string|in:male,female,other',
            'designation' => 'nullable|string|max:100',
            'specialization' => 'nullable|string|max:255',
            'joining_date' => 'nullable|date',
            'branch_id' => 'required|exists:branches,id',
            'employment_type' => 'nullable|string|max:30',
            'basic_salary' => 'nullable|numeric|min:0',
            'commission_type' => 'nullable|string|max:30',
            'commission_value' => 'nullable|numeric|min:0',
            'weekly_off_day' => 'nullable|string|max:20',
            'shift_start_time' => 'nullable|date_format:H:i',
            'shift_end_time' => 'nullable|date_format:H:i',
            'status' => 'required|string|in:active,inactive,on_leave',
            'availability_status' => 'nullable|string|in:available,busy,on_break,off',
            'notes' => 'nullable|string',
            'service_ids' => 'nullable|array',
            'service_ids.*' => 'exists:services,id',
        ];
    }
}
