Edit File: ActivateRequest.php
<?php namespace App\Http\Requests\Api\User\Auth; use App\Enums\OTPType; use App\Models\User; use App\Traits\GeneralTrait; use App\Http\Requests\BaseRequest; class ActivateRequest extends BaseRequest { use GeneralTrait; public function rules() { return [ 'code' => 'required|max:10', 'country_code' => 'required|numeric|digits_between:1,5', 'phone' => 'required|numeric|digits_between:9,11|exists:users,phone,deleted_at,NULL', 'device_id' => 'required|max:250', 'device_type' => 'required|in:ios,android,web', 'mac_address' => 'required|max:250', 'lang' => 'required|in:ar,en', ]; } public function prepareForValidation() { $this->merge([ 'phone' => fixPhone($this->phone), 'country_code' => fixPhone($this->country_code), ]); } public function withValidator($validator) { $validator->after(function ($validator) { $user = User::where(['phone' => $this->phone, 'country_code' => $this->country_code])->first(); if (!$user) { $validator->errors()->add('not_user', trans('auth.failed')); } if (!$this->isCodeCorrect( $this->code, OTPType::VERIFICATION, $user)) { $validator->errors()->add('wrong_code', trans('auth.code_invalid')); } // if ($this->isCodeExpired( $this->code, OTPType::VERIFICATION, $user)) { // $validator->errors()->add('wrong_code', trans('auth.code_expired')); // } }); } }
Back to File Manager