From 16c48f4b0bc6f04d05649149e3342f39e23235c6 Mon Sep 17 00:00:00 2001 From: Ritikesh yadav Date: Tue, 2 Apr 2024 17:32:45 +0530 Subject: [PATCH] update profile verification module --- .../Controllers/Frontend/LoginController.php | 4 +- .../Frontend/ProfileController.php | 92 ++++- public/assets/css/FrontendCss/style.css | 39 +- .../profile/investor-profile-edit.blade.php | 373 ++++++++++++++++-- routes/web.php | 4 + 5 files changed, 480 insertions(+), 32 deletions(-) diff --git a/app/Http/Controllers/Frontend/LoginController.php b/app/Http/Controllers/Frontend/LoginController.php index 193f1fa..16201c8 100644 --- a/app/Http/Controllers/Frontend/LoginController.php +++ b/app/Http/Controllers/Frontend/LoginController.php @@ -268,7 +268,7 @@ class LoginController extends Controller try { $otp = $this->otpGenerate($request->emailorphone); $mailData = [ - 'title' => 'Mail from Freeu.in', + 'title' => 'Mail from Jerichoalternatives.in', 'body' => 'This is for testing email using smtp.' ]; // $otp = $this->otpGenerate($request->email); @@ -284,7 +284,7 @@ class LoginController extends Controller // Session::put('user_id', $user->id); return response()->json(['user_id' => $user->id, 'status' => 200]); } catch (\Exception $e) { - return response()->json(['error' => 'Netwrok Error! Please try again after sometime.', 'status' => 500]); + return response()->json(['error' => 'Network Error! Please try again after sometime.', 'status' => 500]); } } } diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index 65e1f46..7864118 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -6,6 +6,11 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; use App\Models\User; +use Illuminate\Support\Facades\Session; +use Auth; +use App\Mail\OtpMail; +use Mail; +use App\Http\Controllers\Frontend\LoginController as sendOTP; class ProfileController extends Controller { @@ -27,15 +32,15 @@ class ProfileController extends Controller // dd($request->all()); $validator = Validator::make($request->all(), [ 'name' => 'required|regex:/^[a-zA-Z ]+$/u|max:255', - 'email' => 'required|unique:users,email,' . $request->id . '', - 'contact_number' => 'required|numeric|digits:10|unique:users,contact_number,' . $request->id . '', + // 'email' => 'required|unique:users,email,' . $request->id . '', + // 'contact_number' => 'required|numeric|digits:10|unique:users,contact_number,' . $request->id . '', 'profile_image' => 'image|mimes:jpeg,jpg,png|max:2000', 'address' => 'required' ], [ 'required' => 'The :attribute field must be required', - 'unique' => 'The :attribute field must be unique', - 'numeric' => 'The :attribute field must be in digits', - 'digits' => 'The :attribute field must have 10 digits', + // 'unique' => 'The :attribute field must be unique', + // 'numeric' => 'The :attribute field must be in digits', + // 'digits' => 'The :attribute field must have 10 digits', // 'profile_image.mimes' => 'The :attribute can only be of type jpeg,jpg,png' ]); @@ -49,9 +54,9 @@ class ProfileController extends Controller $addUser = User::where('id', $request->id)->update([ 'name' => $request->name, - 'contact_number' => $request->contact_number, + // 'contact_number' => $request->contact_number, 'address' => $request->address, - 'email' => $request->email, + // 'email' => $request->email, 'profile_image' => $image, ]); @@ -156,4 +161,77 @@ class ProfileController extends Controller return $messages; } } + + public function sendEmailOTP(Request $request) + { + $validator = validator::make($request->all(), [ + 'newEmail' => 'required|unique:users,email,' . Auth::guard('users')->user()->id . '', + ], [ + 'required' => 'The :attribute field must be required', + 'unique' => 'The :attribute field must be unique', + ]); + $otp = rand(1000, 9999); + $mailData = [ + 'title' => 'Mail from Jerichoalternatives.in', + 'body' => 'This is for testing email using smtp.' + ]; + Session::put('newEmail', $request->newEmail); + Session::put('otp', $otp); + // Mail::to($request->newEmail)->send(new OtpMail($mailData,$otp)); + return response()->json([ + 'status' => 200, + 'message' => 'OTP sended on enter email', + ]); + } + + public function updateEmail(Request $request) + { + // dd('hello'); + if ($request->email_otp) { + if ((int)$request->email_otp == Session::get('otp')) { + $updateUserProfile = User::where('id', Auth::guard('users')->user()->id)->update([ + 'email' => Session::get('newEmail'), + ]); + Session::forget(['newEmail', 'otp']); + return response()->json(['status' => 200, 'message' => 'Email update successfully']); + } + return response()->json(['status' => 201, 'message' => 'OTP invalid !']); + } + return response()->json(['status' => 201, 'message' => 'Please enter OTP']); + } + + public function sendOTPNumber(Request $request) + { + // dd('hello'); + $validator = validator::make($request->all(), [ + 'newcontact_number' => 'required|unique:users,contact_number,' . Auth::guard('users')->user()->id . '', + ], [ + 'required' => 'The :attribute field must be required', + 'unique' => 'The :attribute field must be unique', + ]); + $otp = rand(1000, 9999); + Session::put('contact_number', $request->newcontact_number); + Session::put('mobile_otp', $otp); + // $sendOTPMessage = (new sendOTP)->thirdPartyOTP($request->contact_number, $otp); + return response()->json([ + 'status' => 200, + 'message' => 'OTP sended to contact number', + ]); + } + + public function updateContactNumber(Request $request) + { + // dd(Session::get('mobile_otp'), Session::get('contact_number'), $request->mobile_otp); + if ($request->mobile_otp) { + if ((int)$request->mobile_otp == Session::get('mobile_otp')) { + $updateUserProfile = User::where('id', Auth::guard('users')->user()->id)->update([ + 'contact_number' => Session::get('contact_number'), + ]); + Session::forget(['contact_number', 'mobile_otp']); + return response()->json(['status' => 200, 'message' => 'Contact number update successfully']); + } + return response()->json(['status' => 201, 'message' => 'OTP invalid !']); + } + return response()->json(['status' => 201, 'message' => 'Please enter OTP']); + } } diff --git a/public/assets/css/FrontendCss/style.css b/public/assets/css/FrontendCss/style.css index 09becc3..ffaf261 100644 --- a/public/assets/css/FrontendCss/style.css +++ b/public/assets/css/FrontendCss/style.css @@ -3784,6 +3784,7 @@ input:focus { cursor: pointer; width: 25%; transition: 0.5s; + background-color: #c18948; } .investor-profile .invest-form .save:hover { background-color: #c18948; @@ -4443,7 +4444,43 @@ span.start { .table-invest .categeory .tables { margin-bottom: 20px; } - +.investor-profile p.edit-invest-profile { + position: relative; +} +.investor-profile .invest-form .edit-invest-profile a { + position: absolute; + right: 5px; + background-color: transparent; + padding: 0; + top: 10px; +} +.edit-modal input { + width: 100%; + padding: 7px; + border: 1px solid #9e9e9e; + border-radius: 5px; + margin-top: 3px; +} +.edit-modal button.cancle-btn { + border-radius: 5px; + padding: 5px 40px; + height: 43px; + font-weight: 400; + border: 1px solid #c18948; + align-items: center; + display: flex; + color: #000; + font-size: 18px; + background-color: transparent; +} +.edit-modal button.yellow-btn { + border: none; + height: 44px; +} +.save span.spinner-border { + top: 7px; + position: relative; +} /*======responsive=====*/ @media (max-width: 2560px) { diff --git a/resources/views/Frontend/Pages/profile/investor-profile-edit.blade.php b/resources/views/Frontend/Pages/profile/investor-profile-edit.blade.php index 19383df..33362f8 100644 --- a/resources/views/Frontend/Pages/profile/investor-profile-edit.blade.php +++ b/resources/views/Frontend/Pages/profile/investor-profile-edit.blade.php @@ -20,14 +20,19 @@

-

+ value="{{ auth()->guard('users')->user()->contact_number }}" class="iv-input"> + +

-

+

+ +

@@ -39,7 +44,7 @@
- + @@ -55,6 +60,136 @@
+ + + + + {{-- email popup close --}} + + {{-- email verify otp modal --}} + + + {{-- email otp modal ends --}} + + + {{-- contact number modal start --}} + + + {{-- mobile popup close --}} + + {{-- mobile verify otp modal --}} + + + {{-- mobile otp modal ends --}} @endsection @section('scripts') @endsection diff --git a/routes/web.php b/routes/web.php index 10eb9e9..b276192 100644 --- a/routes/web.php +++ b/routes/web.php @@ -486,6 +486,10 @@ Route::middleware([FrontendAccess::class])->group(function () { Route::get("investor-profile", [ProfileController::class, 'index'])->name('investor-profile'); Route::get("edit-profile", [ProfileController::class, 'edit'])->name('edit-profile'); Route::patch("update-user-profile", [ProfileController::class, 'update'])->name('update-user-profile'); + Route::patch("send-email-otp", [ProfileController::class, 'sendEmailOTP'])->name('send-email-otp'); + Route::patch("update-user-email", [ProfileController::class, 'updateEmail'])->name('update-user-email'); + Route::patch("send-otp-mobile", [ProfileController::class, 'sendOTPNumber'])->name('send-otp-mobile'); + Route::patch("update-user-contact-number", [ProfileController::class, 'updateContactNumber'])->name('update-user-contact-number'); //Buyer Form Route::controller(MarketPlaceController::class)->group(function () {