<?php

namespace App\Http\Requests;

use App\Models\User;
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;

class ProfileRequest extends FormRequest {
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize() {
        return auth()->check();
    }


    public function rules() {
        return [
            'username' => ['required', 'string', 'max:255'],
            'first_name' => [ 'required', 'string', 'max:255'],
            'last_name' => [ 'required', 'string', 'max:255'],
            'email' => ['required', 'email', Rule::unique((new User)->getTable())->ignore(auth()->id())],
            'phone_number' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|size:10',
            'date_of_birth' => 'nullable|date_format:Y-m-d|before:today',
        ];
    }
}
