From cbda01f16016abbe4ea215876f10e3cf47a819d4 Mon Sep 17 00:00:00 2001 From: sayaliparab Date: Wed, 24 Jul 2024 08:08:12 +0530 Subject: [PATCH] restUser --- .../Admin/RestaurantAppController.php | 103 +++- .../restaurants_users.blade.php | 568 +++++++++++------- routes/web.php | 2 +- 3 files changed, 423 insertions(+), 250 deletions(-) diff --git a/app/Http/Controllers/Admin/RestaurantAppController.php b/app/Http/Controllers/Admin/RestaurantAppController.php index 71c0d67..d6a3406 100644 --- a/app/Http/Controllers/Admin/RestaurantAppController.php +++ b/app/Http/Controllers/Admin/RestaurantAppController.php @@ -85,58 +85,101 @@ class RestaurantAppController extends Controller * Created at : 03 June 2024 * Use : To change the status restaturant user. */ + // public function change_rest_user_status(Request $request) + // { + // try { + // DB::beginTransaction(); + // $status = IamPrincipal::find($request->rest_user_id); + // $status->is_active = $request->status; + + // // Generate a random password if status is 1 (approved) + // if ($request->status == 1) { + // $randomPassword = \Str::random(8); // Adjust the length as per your requirements + // $status->password = bcrypt($randomPassword); // Make sure to hash the password + // } else { + // $status->deleted_by_admin = 1; + // $detail = [ + // 'first_name' => $status->first_name, + // 'last_name' => $status->last_name, + // 'email' => $status->email_address, + // ]; + // Mail::to($status->email_address)->send(new RestUserDisapproval($detail)); + // } + + // $status->save(); + + + + // if ($request->status == 1) { + // // Fetch user data based on user ID + // $user = IamPrincipal::find($request->rest_user_id); + + // if ($user) { + // // Send email only if user exists + // $data = [ + // 'first_name' => $user->first_name, + // 'last_name' => $user->last_name, + // 'email' => $user->email_address, + // 'password' => $randomPassword, // Pass the random password to the email template + // ]; + + // Mail::to($user->email_address)->send(new RestUserApproval($data)); + // } + // } + + // DB::commit(); + + // return jsonResponseWithSuccessMessage(__('success.update_data')); + // } catch (Exception $e) { + // Log::error("Update Status function Load Failed " . $e->getMessage()); + // return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + // } + // } + public function change_rest_user_status(Request $request) { try { DB::beginTransaction(); $status = IamPrincipal::find($request->rest_user_id); $status->is_active = $request->status; - + // Generate a random password if status is 1 (approved) if ($request->status == 1) { $randomPassword = \Str::random(8); // Adjust the length as per your requirements $status->password = bcrypt($randomPassword); // Make sure to hash the password - } else { - $status->deleted_by_admin = 1; - $detail = [ + + // Send approval email + $data = [ 'first_name' => $status->first_name, 'last_name' => $status->last_name, 'email' => $status->email_address, + 'password' => $randomPassword, // Pass the random password to the email template + ]; + + Mail::to($status->email_address)->send(new RestUserApproval($data)); + } else { + + $status->deleted_by_admin = 1; + $detail = [ + 'first_name'=> $status->first_name, + 'last_name' => $status->last_name, + 'email'=> $status->email_address, ]; Mail::to($status->email_address)->send(new RestUserDisapproval($detail)); } - + $status->save(); - - - - if ($request->status == 1) { - // Fetch user data based on user ID - $user = IamPrincipal::find($request->rest_user_id); - - if ($user) { - // Send email only if user exists - $data = [ - 'first_name' => $user->first_name, - 'last_name' => $user->last_name, - 'email' => $user->email_address, - 'password' => $randomPassword, // Pass the random password to the email template - ]; - - Mail::to($user->email_address)->send(new RestUserApproval($data)); - } - } - + DB::commit(); - - return jsonResponseWithSuccessMessage(__('success.update_data')); + + return response()->json(['success' => true]); } catch (Exception $e) { + DB::rollBack(); Log::error("Update Status function Load Failed " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + return response()->json(['success' => false, 'message' => __('auth.something_went_wrong')], 500); } } - - + diff --git a/resources/views/Admin/pages/manage_users/restaurants_app/restaurants_users.blade.php b/resources/views/Admin/pages/manage_users/restaurants_app/restaurants_users.blade.php index 59862c9..288c47e 100644 --- a/resources/views/Admin/pages/manage_users/restaurants_app/restaurants_users.blade.php +++ b/resources/views/Admin/pages/manage_users/restaurants_app/restaurants_users.blade.php @@ -85,6 +85,25 @@ font-size: 14px; /* Adjust font size as needed */ } + + +.modal-body { + text-align: center; +} + +.modal-btn { + gap: 10px; /* Optional: Adds space between the buttons */ +} + +.modal-text { + text-align: center; + margin-bottom: 1.5rem; /* Adjust margin as needed */ +} + +.extra-btn { + margin-right: 10px; /* Adjust margin as needed */ +} +
@@ -315,53 +334,72 @@
+ + + + + + + + + @endsection @section('section_script') -