Edit File: UpdatePhoneSendCodeRequest.php
<?php namespace App\Http\Requests\Api\User\Profile; use App\Http\Requests\BaseRequest; class UpdatePhoneSendCodeRequest extends BaseRequest { public function rules() { // get current route action $action = request()->route()->getActionMethod(); $data = [ 'country_code' => 'required|numeric|digits_between:1,5', ]; $data['phone'] = $action === 'sendCodeToOldPhone' ? 'required|numeric|digits_between:9,11|exists:users,phone' : 'required|numeric|digits_between:9,11|unique:users,phone,NULL,id,deleted_at,NULL'; return $data; } public function prepareForValidation() { $this->merge([ 'phone' => fixPhone($this->phone), 'country_code' => fixPhone($this->country_code), ]); } }
Back to File Manager