<?php

namespace App\Http\Requests\Member;

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

// ══════════════════════════════════════════════════════════════════
//  InPractice — UpdateProfileRequest
//  Location: app/Http/Requests/Member/UpdateProfileRequest.php
// ══════════════════════════════════════════════════════════════════

class UpdateProfileRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'name'             => ['required', 'string', 'min:2', 'max:100'],
            'nickname'         => [
                'required', 'string', 'min:3', 'max:30',
                'alpha_dash',
                Rule::unique('users', 'nickname')->ignore($this->user()->id),
            ],
            'profession'       => ['nullable', 'string', 'max:100'],
            'experience_level' => ['nullable', 'string', 'in:student,fresh,junior,mid,senior,senior_10,senior_15,senior_20'],
            'sector'           => ['nullable', 'string', 'max:100'],
            'bio'              => ['nullable', 'string', 'max:500'],
        ];
    }

    public function messages(): array
    {
        return [
            'name.required'             => __('profile.validation_name_required'),
            'name.min'                  => __('profile.validation_name_min'),
            'nickname.required'         => __('profile.validation_nickname_required'),
            'nickname.min'              => __('profile.validation_nickname_min'),
            'nickname.alpha_dash'       => __('profile.validation_nickname_format'),
            'nickname.unique'           => __('profile.validation_nickname_taken'),
            'experience_level.in'       => __('profile.validation_experience_invalid'),
            'bio.max'                   => __('profile.validation_bio_max'),
        ];
    }
}