diff --git a/app/Http/Controllers/Admin/ManageRestrauntController.php b/app/Http/Controllers/Admin/ManageRestrauntController.php index 39392bf..c8d2963 100644 --- a/app/Http/Controllers/Admin/ManageRestrauntController.php +++ b/app/Http/Controllers/Admin/ManageRestrauntController.php @@ -74,63 +74,72 @@ class ManageRestrauntController extends Controller public function edit_restaurant(Request $request, $id) { try { - $hours = OperatingHour::where('manage_restaurant_xid', $id)->get(); + $operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week'); $restaurantItem = ManageRestaurant::where('id', $id)->first(); $restaurantItem['image'] = ListingImageUrl('restaurant_images', $restaurantItem['image']); - // dd($voucherItem); return view( 'Admin.pages.manage_restaurants.edit_restaurant', compact( 'restaurantItem', - 'hours' + 'operating_hours' ) ); } catch (Exception $e) { Log::error("edit voucher Page Load Failed " . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } - } - // public function update(Request $request) - // { - // try { - // dd($request); - // DB::beginTransaction(); - // $restaurant = ManageRestaurant::where('id', $request->restaurant_id)->first(); - // // dd($passport_data); - // if (isset($request->image)) { - // $image = $request->image; - // $image_db = null; - // } else { - // $image = null; - // $image_db = $restaurant->image; - // } - // $normalImage = saveSingleImageWithoutCrop($image, 'restaurant_images', $image_db); + public function update(Request $request) + { + try { + DB::beginTransaction(); - // $restaurant->restaurant_name = $request->input('name'); - // $restaurant->description = $request->input('description'); + $restaurant = ManageRestaurant::where('id', $request->id)->first(); - // $restaurant->image = $normalImage; - // $restaurant->restaurant_id = $request->input('rest_id'); - // $restaurant->city_xid = $request->input('city'); - // $restaurant->bio = $request->input('bio'); - // $restaurant->try_on_1 = $request->input('try_on_1'); - // $restaurant->try_on_2 = $request->input('try_on_2'); - // $restaurant->try_on_3 = $request->input('try_on_3'); - // $restaurant->try_on_4 = $request->input('try_on_4'); - // $restaurant->save(); + if ($request->hasFile('image')) { + $image = $request->file('image'); + $imagePath = saveSingleImageWithoutCrop($image, 'restaurant_images'); + } else { + $imagePath = $restaurant->image; + } - // DB::commit(); + $restaurant->name = $request->input('name'); + $restaurant->description = $request->input('description'); + $restaurant->image = $imagePath; + $restaurant->restaurant_id = $request->input('restaurant_id'); + $restaurant->address = $request->input('location_name'); + $restaurant->exclusion = $request->input('exclusion'); + $restaurant->latitude = $request->input('latitude'); + $restaurant->longtitude = $request->input('longitude'); + $restaurant->bio = $request->input('bio'); + $restaurant->try_on_1 = $request->input('try_on_1'); + $restaurant->try_on_2 = $request->input('try_on_2'); + $restaurant->try_on_3 = $request->input('try_on_3'); + $restaurant->try_on_4 = $request->input('try_on_4'); + $restaurant->save(); - // return jsonResponseWithSuccessMessage(__('success.update_data')); - // } catch (Exception $e) { - // DB::rollBack(); - // Log::error("update Restaurant Services Page Load Failed " . $e->getMessage()); - // return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); - // } - // } + OperatingHour::where('manage_restaurant_xid', $restaurant->id)->delete(); + + foreach ($request->input('operating_hours') as $day => $hours) { + OperatingHour::create([ + 'manage_restaurant_xid' => $restaurant->id, + 'day_of_week' => $day, + 'start_time' => $hours['start_time'], + 'end_time' => $hours['end_time'] + ]); + } + + DB::commit(); + + return jsonResponseWithSuccessMessage(__('success.update_data')); + } catch (Exception $e) { + DB::rollBack(); + Log::error("update Restaurant Services Page Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } } diff --git a/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php b/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php index 7302634..079535f 100644 --- a/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php +++ b/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php @@ -165,4 +165,9 @@ allowClear: true }); + @endsection diff --git a/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php b/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php index 7b29564..515d9bf 100644 --- a/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php +++ b/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php @@ -4,6 +4,20 @@ @php $currentPage = 'restraunt'; @endphp +
@@ -37,19 +51,18 @@
-
+
-
- {!! $restaurantItem->description !!}
- +
+
- +
@@ -67,8 +80,28 @@
+ name="location_name" value="{{ $restaurantItem->address }}" maxlength="100"> +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
@@ -90,13 +123,32 @@ value="{{ $restaurantItem->try_on_3 }}"> - +
+
+
+
+ + @foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day) +
+
+ + +
+
+ + +
+
+ @endforeach
-
@@ -155,11 +207,133 @@ } }); - - - - - @endsection @section('section_script') + @endsection diff --git a/routes/web.php b/routes/web.php index 0c14a37..a3afc2c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -130,15 +130,18 @@ Route::get('/manage-feedback', [ManageFeedbackController ::class, 'index'])->na //*******************************************************manage notification******************************************************** Route::get('/manage-notification', [ManageNotificationsController ::class, 'index'])->name('manage.notification'); -}); - - - - //*******************************************************manage restraunts******************************************************** Route::get('/manage-restaurants', [ManageRestrauntController ::class, 'index'])->name('manage.restaurants'); Route::get('/manage_restaurant_add', [ManageRestrauntController::class, 'add'])->name('add_manage_restraunt'); Route::post('/store_restaurant', [ManageRestrauntController::class, 'store_restaurant']); Route::get('/edit_restaurant/{id}', [ManageRestrauntController::class, 'edit_restaurant'])->name('edit_restaurant'); -Route::post('/update_restaurant', [ManageRestrauntController::class, 'update']); +Route::post('/update_restaurant', [ManageRestrauntController::class, 'update'])->name('update_restaurant'); + + +}); + + + + +