<?php

namespace App\Http\Requests\V3\Dashboard\UserManagement;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UpdateRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'province_id' => 'required|exists:provinces,id',
            'edarate_ostani_id' => 'exists:edarate_ostanis,id',
            'city_id' => 'exists:cities,id',
            'edarate_shahri_id' => 'exists:edarate_shahris,id',
            'username' => ['required',Rule::unique('users','username')->ignore($this->user->id)],
            'national_code' =>['required',Rule::unique('users','national_code')->ignore($this->user->id)],
            'password' => 'required|min:8',
        ];
    }
}
