<?php

namespace App\Http\Requests\Profile;

use Illuminate\Foundation\Http\FormRequest;

class UpdateProfileRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        // Get the current user's ID
        $userId = $this->user()->id;

        return [
            'name' => 'sometimes|string|max:255',
            'email' => 'sometimes|string|email|max:255|unique:users,email,'.$userId,
            'password' => 'sometimes|string|min:8',
            'phone' => 'sometimes|string|unique:users,phone,'.$userId,
            'gender' => 'sometimes|in:male,female',
            'city_id' => 'sometimes|exists:cities,id',
            'region_id' => 'sometimes|exists:regions,id',
        ];
    }
}
