PATH:
home
/
rwabteecom
/
project_11
/
app
/
Services
/
Authentication
/
Editing: ForgetPasswordServices.php
<?php namespace App\Services\Authentication; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Validation\ValidationException; class ForgetPasswordServices extends BaseAuthenticationService { protected $request; protected $auth; public function __construct($request, $auth) { $this->request = $request; $this->auth = new $auth(); } public function sendOtpCode(): void { $this->ensureIsNotRateLimited(); $auth = $this->auth->where('phone', $this->request->string("phone")->toString())->first(); if (!$auth) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ "auth" => __('auth.failed') ]); } $otpCode = 999999; // if (config('app.env') == "local") { // // $otpCode = 999999; // // } else { // // $otpCode = random_int(000_000, 999_999); // // } $auth->update([ "hashed_otp" => Hash::make($otpCode) ]); RateLimiter::clear($this->throttleKey()); } }
SAVE
CANCEL