<?php

namespace App\Http\Requests\Admin\UserManagement;

use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;

class StoreRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, ValidationRule|array|string>
     */
    public function rules(): array
    {
        return [
            'full_name' => 'required|max:255|string',
            'username' => 'required|unique:users,username|string',
            'position' => 'required',
            'gender' => 'required|in:male,female',
            'national_id' => 'required|digits:10|unique:users,national_id',
            'phone_number' => 'required|numeric|digits:11|unique:users,phone_number|regex:/^09\d{9}$/',
            'province_id' => 'required|exists:provinces,id',
            'password' => 'required|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:8',
            'role_id' => 'required|exists:roles,id',
            'email' => 'email|unique:users,email',
            'telephone_id' => 'required|numeric|unique:users,telephone_id',
        ];
    }
}
