<?php

namespace Mehrab\User\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Mehrab\Service\Models\Service;
use Mehrab\User\Models\User;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        //* password doesnt need exact register rules
        $id = $this->user;
        return [
            'mobile' => ['required','regex:/^(09)[0-9]{9}/', 'digits:11', 'numeric',Rule::unique('users','mobile')->ignore($id)],
            'password' => ['nullable','string', 'min:6'],
            'name' => ['nullable','string','min:2','max:200'],
            'lname' => ['nullable','string','min:2','max:200'],
            'national_code' => ['nullable','numeric','digits:10',Rule::unique('users','national_code')->ignore($id)],
            'email' => ['nullable','email',Rule::unique('users','email')->ignore($id)],
            'status' => ['required',Rule::in(User::$status)],
            'amount' => ['nullable','numeric'],
            'zip_code' => ['nullable','array'],
            'zip_code.*' => ['nullable','numeric'],
            'address' => ['nullable','array'],
            'address.*' => ['nullable','string','min:2','max:2000'],
            'profile_pic' => ['nullable','image','mimes:jpg,jpeg,png','max:2048'],
            'certificate_card_pic' => ['nullable','image','mimes:jpg,jpeg,png','max:2048'],
            'national_card_pic' => ['nullable','image','mimes:jpg,jpeg,png','max:2048'],
            'delـprofile_pic' => ['nullable',Rule::in(['on'])],
            'delـcertificate_pic' => ['nullable',Rule::in(['on'])],
            'del_national_card_pic_id' => ['nullable',Rule::in(['on'])],

        ];
    }

}
