diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/RestaurantControllerApi.php b/app/Http/Controllers/Admin/APIs/Customer_API/RestaurantControllerApi.php index 5247dc9..a280ace 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/RestaurantControllerApi.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/RestaurantControllerApi.php @@ -25,15 +25,15 @@ class RestaurantControllerApi extends Controller public function getCoordinates() { try { - $token = readHeaderToken(); + // $token = readHeaderToken(); - if ($token) { - $customerIamId = $token['sub']; - $response = $this->RestaurantApiServices->getCoordinates($customerIamId); + // if ($token) { + // $customerIamId = $token['sub']; + $response = $this->RestaurantApiServices->getCoordinates(); return $response; - } else { - return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); - } + // } else { + // return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + // } } catch (\Exception $e) { Log::error('Passport function failed: ' . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); diff --git a/app/Http/Controllers/Admin/ManageCustomerController.php b/app/Http/Controllers/Admin/ManageCustomerController.php index 547e33f..48b2441 100644 --- a/app/Http/Controllers/Admin/ManageCustomerController.php +++ b/app/Http/Controllers/Admin/ManageCustomerController.php @@ -1,6 +1,7 @@ orderBy('created_at', 'desc')->get(); - - // // foreach ($customers as $customer) { - // // $activePassportCount = OrderedPassport::where('iam_principal_xid', $customer->id) - // // ->where('is_active', 1) // Assuming 'status' field indicates the status of the passport - // // ->count(); - // // $customer->activePassportCount = $activePassportCount; - // // } - // return view('Admin.pages.manage_users.manage_customer.customer', compact('customers')); - // } catch (Exception $e) { - // Log::error("Manage Voucher Page Not Load " . $e->getMessage()); - // return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); - // } - // } public function index() -{ - try { - // Eager load the state relationship for all customers - $customers = IamPrincipal::where('principal_type_xid', 3) - ->with('state') - ->orderBy('created_at', 'desc') - ->get(); + { + try { + // Eager load the state relationship for all customers + $customers = IamPrincipal::where('principal_type_xid', 3) + ->with('state') + ->orderBy('created_at', 'desc') + ->get(); - return view('Admin.pages.manage_users.manage_customer.customer', compact('customers')); - } catch (Exception $e) { - Log::error("Manage Voucher Page Not Load " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + return view('Admin.pages.manage_users.manage_customer.customer', compact('customers')); + } catch (Exception $e) { + Log::error("Manage Voucher Page Not Load " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } } -} -public function view_customer($id) -{ + public function view_customer($id) + { - try { - $customers_data = IamPrincipal::findOrFail($id); - return view('Admin.pages.manage_users.manage_customer.view_customer_details', compact('customers_data')); - } catch (Exception $e) { - Log::error("Manage Voucher Page Not Load " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + try { + $customers_data = IamPrincipal::findOrFail($id); + return view('Admin.pages.manage_users.manage_customer.view_customer_details', compact('customers_data')); + } catch (Exception $e) { + Log::error("Manage Voucher Page Not Load " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } } -} -public function edit_customer($id) -{ + public function edit_customer($id) + { - try { - $customers_data = IamPrincipal::findOrFail($id); - return view('Admin.pages.manage_users.manage_customer.edit_customer', compact('customers_data')); - } catch (Exception $e) { - Log::error("Manage Voucher Page Not Load " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + try { + $customers_data = IamPrincipal::findOrFail($id); + return view('Admin.pages.manage_users.manage_customer.edit_customer', compact('customers_data')); + } catch (Exception $e) { + Log::error("Manage Voucher Page Not Load " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } } -} -public function update(Request $request) -{ + public function update(Request $request) + { - try { - DB::beginTransaction(); - $customer_data = IamPrincipal::where('id', $request->customer_id)->first(); - $customer_data->first_name = $request->input('name'); - $customer_data->last_name = $request->input('last_name'); + try { + DB::beginTransaction(); + $customer_data = IamPrincipal::where('id', $request->customer_id)->first(); + $customer_data->first_name = $request->input('name'); + $customer_data->last_name = $request->input('last_name'); - $customer_data->phone_number = $request->input('phone'); - $customer_data->email_address = $request->input('email_id'); - $customer_data->save(); - DB::commit(); + $customer_data->phone_number = $request->input('phone'); + $customer_data->email_address = $request->input('email_id'); + $customer_data->save(); + DB::commit(); - return jsonResponseWithSuccessMessage(__('success.update_data')); - } catch (Exception $e) { - DB::rollBack(); - Log::error("updateCustomerNewsArticle Services Page Load Failed " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + return jsonResponseWithSuccessMessage(__('success.update_data')); + } catch (Exception $e) { + DB::rollBack(); + Log::error("updateCustomerNewsArticle Services Page Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } } -} -public function archive_customer() -{ - /* + public function archive_customer() + { + /* Created By : Sayali Parab Created at : 28 May 2024 Use : To Get archieve customer. */ - try { - $customers = IamPrincipal::where('principal_type_xid', 3)->onlyTrashed()->latest()->get(); - return view('Admin.pages.manage_users.manage_customer.archive_manage_customer', compact('customers')); - } catch (Exception $e) { - Log::error("Manage Voucher Page Not Load " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + try { + $customers = IamPrincipal::where('principal_type_xid', 3)->onlyTrashed()->latest()->get(); + return view('Admin.pages.manage_users.manage_customer.archive_manage_customer', compact('customers')); + } catch (Exception $e) { + Log::error("Manage Voucher Page Not Load " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } + + + public function delete_customer($id) + { + + try { + DB::beginTransaction(); + + $passport = IamPrincipal::find($id); + $passport->one_signal_player_id = null; + $passport->deleted_by_admin = 1; + $passport->save(); + + $passport->delete(); + // dd($passport); + DB::commit(); + + return response()->json(['success' => true, 'status' => 200]); + } catch (Exception $e) { + DB::rollBack(); + Log::error("delete_passport function Load Failed " . $e->getMessage()); + return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); + } + } + + public function download_pdf($id) + { + try { + $customers_data = IamPrincipal::findOrFail($id); + $data = [ + 'customers_data' => $customers_data + ]; + + $pdf = PDF::loadView('Admin.pages.manage_users.manage_customer.view_customer_details_pdf', $data); + return $pdf->download('customer_details.pdf'); + } catch (Exception $e) { + Log::error("Error generating PDF: " . $e->getMessage()); + return response()->json(['error' => __('auth.something_went_wrong')], 500); + } + } + + + // public function exportSelectedCustomer(Request $request) + // { + + // try { + + // if ($request->has('all_id')) { + // return Excel::download(new customer_export, 'Passport_data.xlsx'); + // } + + // $ids = $request->selected_id; + + // $fileName = 'selected_customer_data.xlsx'; + // return Excel::download(new customer_export_selected($ids), $fileName); + // } catch (\Exception $e) { + // return response()->json(['error' => 'Export failed. Something went wrong.'], 500); + // } + // } + + + public function unarchive_customer($id) + { + + try { + DB::beginTransaction(); + IamPrincipal::withTrashed()->where('id', $id)->restore(); + + DB::commit(); + + return response()->json(['success' => true, 'status' => 200]); + } catch (Exception $e) { + DB::rollBack(); + Log::error("delete_passport function Load Failed " . $e->getMessage()); + return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); + } } } - - -public function delete_customer($id) -{ - - try { - DB::beginTransaction(); - - $passport = IamPrincipal::find($id); - $passport->one_signal_player_id = null; - $passport->deleted_by_admin = 1; - $passport->save(); - - $passport->delete(); - // dd($passport); - DB::commit(); - - return response()->json(['success' => true, 'status' => 200]); - } catch (Exception $e) { - DB::rollBack(); - Log::error("delete_passport function Load Failed " . $e->getMessage()); - return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); - } -} - -public function download_pdf($id) -{ - try { - $customers_data = IamPrincipal::findOrFail($id); - $data = [ - 'customers_data' => $customers_data - ]; - - $pdf = PDF::loadView('Admin.pages.manage_users.manage_customer.view_customer_details_pdf', $data); - return $pdf->download('customer_details.pdf'); - } catch (Exception $e) { - Log::error("Error generating PDF: " . $e->getMessage()); - return response()->json(['error' => __('auth.something_went_wrong')], 500); - } -} - - -// public function exportSelectedCustomer(Request $request) -// { - -// try { - -// if ($request->has('all_id')) { -// return Excel::download(new customer_export, 'Passport_data.xlsx'); -// } - -// $ids = $request->selected_id; - -// $fileName = 'selected_customer_data.xlsx'; -// return Excel::download(new customer_export_selected($ids), $fileName); -// } catch (\Exception $e) { -// return response()->json(['error' => 'Export failed. Something went wrong.'], 500); -// } -// } - - - -} diff --git a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php index b5aa011..228af4a 100644 --- a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php +++ b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Log; class RestaurantApiServices { - public function getCoordinates($customerIamId) + public function getCoordinates() { try { $restaurant = ManageRestaurant::select( diff --git a/resources/views/Admin/pages/mail/rest_user_approval.blade.php b/resources/views/Admin/pages/mail/rest_user_approval.blade.php new file mode 100644 index 0000000..4b4a2e8 --- /dev/null +++ b/resources/views/Admin/pages/mail/rest_user_approval.blade.php @@ -0,0 +1,20 @@ + + +
+ + +Hello {{ $content['first_name'] }} {{ $content['last_name'] }}
+Your request has been approved. Here are the details:
+Thank you!
+ + diff --git a/routes/customer_api.php b/routes/customer_api.php index e77d963..78d7635 100644 --- a/routes/customer_api.php +++ b/routes/customer_api.php @@ -8,6 +8,7 @@ use App\Http\Controllers\Admin\APIs\Customer_API\RestaurantControllerApi; use Illuminate\Support\Facades\Route; +Route::get('/v1/list-of-coordinates', [RestaurantControllerApi::class, 'getCoordinates']); Route::middleware(['customerApiBasicAuth'])->group(function () { @@ -46,7 +47,6 @@ Route::post('/v1/delete_account', [CustomerControllerApi::class, 'destroyAccount //*******************************************************Restaurant******************************************************** -Route::get('/v1/list-of-coordinates', [RestaurantControllerApi::class, 'getCoordinates']); Route::post('/v1/add-to-favourite', [RestaurantControllerApi::class, 'addToFavourite']); Route::get('/v1/list-of-fav-restaurant', [RestaurantControllerApi::class, 'listFavRestaurant']); diff --git a/routes/web.php b/routes/web.php index c05242d..5ea5582 100644 --- a/routes/web.php +++ b/routes/web.php @@ -52,6 +52,8 @@ Route::get('/manage_customer_archive', [ManageCustomerController::class, 'archiv Route::delete('/manage_customer_archive/{id}', [ManageCustomerController::class, 'delete_customer']); Route::get('/create-pdf-file/{id}', [ManageCustomerController::class, 'download_pdf']); Route::post('/export_selected_customer', [ManageCustomerController::class, 'exportSelectedCustomer'])->name('export-selected-customer'); +Route::post('/manage_customer_unarchive/{id}', [ManageCustomerController::class, 'unarchive_customer']); + //******************************************************* restraunts APP******************************************************** // Route::get('/manage-restaurants_app', [RestaurantAppController ::class, 'index'])->name('manage.restaurants_app');