From fdc7103b567e3ba3a0728b0aa3767c7fbad500d6 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Thu, 6 Jun 2024 15:20:56 +0530 Subject: [PATCH] changes --- .../Admin/RestaurantAppController.php | 33 +++++-------------- app/Models/IamPrincipalRestaurantRole.php | 12 +++++-- .../view_restaurant_users.blade.php | 22 +++++-------- 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/app/Http/Controllers/Admin/RestaurantAppController.php b/app/Http/Controllers/Admin/RestaurantAppController.php index a0131c6..cbe437c 100644 --- a/app/Http/Controllers/Admin/RestaurantAppController.php +++ b/app/Http/Controllers/Admin/RestaurantAppController.php @@ -172,37 +172,20 @@ class RestaurantAppController extends Controller * Created at : 03 June 2024 * Use : To view restaturant user. */ - + public function view_rest($id) { try { - $restaurantView = IamPrincipal::with('restaurant')->findOrFail($id); - - // Check if restaurant_users is not null before iterating over it - if (!is_null($restaurantView->restaurant_users)) { - foreach ($restaurantView->restaurant_users as $user) { - $restaurantIds = $user->getresturant->pluck('restaurant_xid')->toArray(); - - $userRestaurants = ManageRestaurant::whereIn('id', $restaurantIds) - ->select('id', 'name', 'image', 'address', 'latitude', 'longtitude') - ->get(); - - foreach ($userRestaurants as $restaurant) { - $restaurant->image = ListingImageUrl('restaurant_images', $restaurant->image); - } - - $user->restaurants = $userRestaurants; - } - } - // return $restaurantView; - - return view('Admin.pages.manage_users.restaurants_app.view_restaurant_users', compact('restaurantView')); + $restdata = IamPrincipalRestaurantRole::with('restaurant','customer')->where('principal_xid', $id)->first(); + // return $restdata; + + return view('Admin.pages.manage_users.restaurants_app.view_restaurant_users', compact('restdata')); } catch (Exception $e) { Log::error("Manage Voucher Page Not Load " . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } - + /** @@ -295,13 +278,13 @@ class RestaurantAppController extends Controller throw new Exception('Restaurant not found.'); } - + $rest_data->first_name = $request->input('first_name'); $rest_data->last_name = $request->input('last_name'); $rest_data->phone_number = $request->input('restaurant_phone'); $rest_data->date_of_birth = $request->input('user_birth'); - + $rest_data->save(); diff --git a/app/Models/IamPrincipalRestaurantRole.php b/app/Models/IamPrincipalRestaurantRole.php index 5fcc673..295b360 100644 --- a/app/Models/IamPrincipalRestaurantRole.php +++ b/app/Models/IamPrincipalRestaurantRole.php @@ -17,7 +17,13 @@ class IamPrincipalRestaurantRole extends Model 'created_by', 'modified_by', ]; - - - + + public function restaurant() + { + return $this->belongsTo(ManageRestaurant::class, 'restaurant_xid', 'id'); + } + public function customer() + { + return $this->belongsTo(IamPrincipal::class, 'principal_xid', 'id'); + } } diff --git a/resources/views/Admin/pages/manage_users/restaurants_app/view_restaurant_users.blade.php b/resources/views/Admin/pages/manage_users/restaurants_app/view_restaurant_users.blade.php index b0e5f17..2e7c4f0 100644 --- a/resources/views/Admin/pages/manage_users/restaurants_app/view_restaurant_users.blade.php +++ b/resources/views/Admin/pages/manage_users/restaurants_app/view_restaurant_users.blade.php @@ -41,19 +41,14 @@ $currentPage = 'manage-restaurant_app'; - - - - {{ !empty($restaurantView->restaurant) ? $restaurantView->restaurant[0]->name : 'NA' }} + {{ $restdata->restaurant->name ?? 'NA' }} + {{ $restdata->restaurant->id ?? 'NA' }} + {{ $restdata->customer->email_address ?? 'NA' }} + {{ $restdata->customer->created_at ?? 'NA' }} - {{ !empty($restaurantView->restaurant) ? $restaurantView->restaurant[0]->restaurant_id : 'NA' }} - {{ $restaurantView->email_address }} - - {{ \Carbon\Carbon::parse($restaurantView->date_of_birth)->format('d/m/Y') }} - - + @@ -70,9 +65,8 @@ $currentPage = 'manage-restaurant_app'; While at Restaurant be sure to try : --> - {{ $restaurantView->state->name}} - - {{ $restaurantView->phone_number}} + {{ $restdata->customer->state_xid}} + {{ $restdata->customer->phone_number}}