diff --git a/app/Http/Controllers/APIs/Customer_API/AuthController.php b/app/Http/Controllers/APIs/Customer_API/AuthController.php index 93812ae..3427bdc 100644 --- a/app/Http/Controllers/APIs/Customer_API/AuthController.php +++ b/app/Http/Controllers/APIs/Customer_API/AuthController.php @@ -101,7 +101,7 @@ class AuthController extends Controller } }, ], - 'phone_number' => 'required|min:10', + 'phone_number' => 'required|numeric|min:10', // 'address_line1' => 'required|max:50', 'state_xid' => 'required', diff --git a/app/Http/Controllers/Admin/ManageRestrauntController.php b/app/Http/Controllers/Admin/ManageRestrauntController.php index 3546f07..123ebc1 100644 --- a/app/Http/Controllers/Admin/ManageRestrauntController.php +++ b/app/Http/Controllers/Admin/ManageRestrauntController.php @@ -89,14 +89,14 @@ class ManageRestrauntController extends Controller $restaurant->save(); // Storing operating hours - 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'] - ]); - } + // 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'] + // ]); + // } // Storing restaurant time interval $restTimeInterval = new RestaurantTimeInterval(); @@ -107,7 +107,7 @@ class ManageRestrauntController extends Controller $restTimeInterval->save(); // Storing closed restaurant date and time - if ($request->has('closed_date')) { + if ($request->filled('closed_date')) { $ClosedTime = new RestaurantClosedHour(); $ClosedTime->restaurant_id = $restaurant->id; $ClosedTime->day = $request->closed_date; @@ -157,7 +157,7 @@ class ManageRestrauntController extends Controller public function edit_restaurant(Request $request, $id) { try { - $operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week'); + // $operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week'); $restaurantItem = ManageRestaurant::with('timeInterval')->where('id', $id)->first(); $restaurantClosedTime = RestaurantClosedHour::with('restaurant')->where('restaurant_id', $id)->first(); $timeInterval = $restaurantItem->timeInterval->first(); @@ -169,7 +169,7 @@ class ManageRestrauntController extends Controller compact( 'restaurantItem', - 'operating_hours', + // 'operating_hours', 'state', 'timeInterval', 'restaurantClosedTime' @@ -218,27 +218,27 @@ class ManageRestrauntController extends Controller $restaurant->save(); // Handle operating hours - foreach ($request->input('operating_hours') as $day => $hours) { - $operatingHour = OperatingHour::where('manage_restaurant_xid', $restaurant->id) - ->where('day_of_week', $day) - ->first(); + // foreach ($request->input('operating_hours') as $day => $hours) { + // $operatingHour = OperatingHour::where('manage_restaurant_xid', $restaurant->id) + // ->where('day_of_week', $day) + // ->first(); - if ($operatingHour) { - // Update existing record - $operatingHour->update([ - 'start_time' => $hours['start_time'], - 'end_time' => $hours['end_time'] - ]); - } else { - // Create new record - OperatingHour::create([ - 'manage_restaurant_xid' => $restaurant->id, - 'day_of_week' => $day, - 'start_time' => $hours['start_time'], - 'end_time' => $hours['end_time'] - ]); - } - } + // if ($operatingHour) { + // // Update existing record + // $operatingHour->update([ + // 'start_time' => $hours['start_time'], + // 'end_time' => $hours['end_time'] + // ]); + // } else { + // // Create new record + // OperatingHour::create([ + // 'manage_restaurant_xid' => $restaurant->id, + // 'day_of_week' => $day, + // 'start_time' => $hours['start_time'], + // 'end_time' => $hours['end_time'] + // ]); + // } + // } // Handle time interval $timeInterval = RestaurantTimeInterval::where('manage_restaurants_xid', $restaurant->id)->first(); @@ -263,15 +263,13 @@ class ManageRestrauntController extends Controller // Handle closed restaurant data $closedTime = RestaurantClosedHour::where('restaurant_id', $restaurant->id)->first(); - if ($closedTime) { - // Update existing record + if ($closedTime && $request->has('closed_date')) { $closedTime->update([ 'day' => $request->input('closed_date'), 'start_time' => $request->input('closed_start_time'), 'end_time' => $request->input('closed_end_time'), ]); - } else { - // Create new record + } elseif ($request->filled('closed_date')) { RestaurantClosedHour::create([ 'restaurant_id' => $restaurant->id, 'day' => $request->input('closed_date'), @@ -280,6 +278,7 @@ class ManageRestrauntController extends Controller ]); } + DB::commit(); return jsonResponseWithSuccessMessage(__('success.update_data')); @@ -321,6 +320,7 @@ Use : To Update status of restaurant. */ public function updateRestaurantStatus(Request $request) { + dd($request); try { DB::beginTransaction(); $voucher_data = ManageRestaurant::where('id', $request->dataId)->first(); diff --git a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php index 25ed6dc..cd78742 100644 --- a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php +++ b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php @@ -180,7 +180,7 @@ class RestaurantApiServices public function DetailRestaurant($customerIamId, $id) { try { - $rest = ManageRestaurant::select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'state_xid') + $rest = ManageRestaurant::with('closedRestaurant')->select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'state_xid') ->where('short_id', $id) ->where('is_active', '1') ->first(); @@ -540,7 +540,7 @@ Log::info($restAllowedRedeemTime); public function searchRestaurant($customerIamId, $request) { try { - $restaurantsQuery = ManageRestaurant::with(['operatingHours', 'state']) + $restaurantsQuery = ManageRestaurant::with('state','closedRestaurant') ->where('is_active', '1'); $searchData = $request->input('search_data'); @@ -558,11 +558,74 @@ Log::info($restAllowedRedeemTime); $restaurants = $restaurantsQuery->get(); - foreach ($restaurants as &$res) { - $res['image'] = ListingImageUrl('restaurant_images', $res['image']); - $res['is_favourite'] = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId) - ->where('restaurant_xid', $res->id) + $client = new Client(); + $promises = []; + $googlePlaceApiKey = config('constants.googlePlaces.api_key'); + + foreach ($restaurants as &$restaurant) { + $restaurant['image'] = ListingImageUrl('restaurant_images', $restaurant['image']); + $isFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId) + ->where('restaurant_xid', $restaurant['id']) ->exists(); + $restaurant['is_favourite'] = $isFavourite; + + $cacheKey = 'restaurant_hours_' . $restaurant['name']; + if (Cache::has($cacheKey)) { + $restaurant['operating_hours'] = Cache::get($cacheKey); + } else { + // Prepare the first request to get the place_id + $promises[$restaurant['name']] = $client->getAsync('https://maps.googleapis.com/maps/api/place/findplacefromtext/json', [ + 'query' => [ + 'fields' => 'place_id', + 'input' => $restaurant['name'], + 'inputtype' => 'textquery', + 'key' => $googlePlaceApiKey + ] + ]); + } + } + + // Execute all the first requests concurrently + $results = Utils::settle($promises)->wait(); + + $detailPromises = []; + foreach ($restaurants as &$restaurant) { + if (isset($results[$restaurant['name']]['value'])) { + $response = $results[$restaurant['name']]['value']; + $placeData = json_decode($response->getBody(), true); + + if (isset($placeData['candidates'][0]['place_id'])) { + $placeId = $placeData['candidates'][0]['place_id']; + + // Prepare the second request to get the operating hours + $detailPromises[$restaurant['name']] = $client->getAsync('https://maps.googleapis.com/maps/api/place/details/json', [ + 'query' => [ + 'fields' => 'opening_hours', + 'place_id' => $placeId, + 'key' => $googlePlaceApiKey + ] + ]); + } else { + $restaurant['operating_hours'] = "N/A"; + } + } + } + + // Execute all the second requests concurrently + $detailResults = Utils::settle($detailPromises)->wait(); + + foreach ($restaurants as &$restaurant) { + if (isset($detailResults[$restaurant['name']]['value'])) { + $response = $detailResults[$restaurant['name']]['value']; + $data = json_decode($response->getBody(), true); + if (isset($data['result']['opening_hours']['weekday_text'])) { + $hours = $data['result']['opening_hours']['weekday_text']; + Cache::put('restaurant_hours_' . $restaurant['name'], $hours, now()->addHours(24)); + $restaurant['operating_hours'] = $hours; + } else { + $restaurant['operating_hours'] = "N/A"; + } + } } return jsonResponseWithSuccessMessageApi(__('auth.restaurant_search'), $restaurants, 200); @@ -573,4 +636,5 @@ Log::info($restAllowedRedeemTime); ], 500); } } + } diff --git a/app/Services/APIs/RestaurantService/RedeemApiService.php b/app/Services/APIs/RestaurantService/RedeemApiService.php index fd29ff4..5ea8390 100644 --- a/app/Services/APIs/RestaurantService/RedeemApiService.php +++ b/app/Services/APIs/RestaurantService/RedeemApiService.php @@ -108,7 +108,7 @@ class RedeemApiService public function undoRedemption($restIamId, $request) { try { - $voucherDetail = RedeemRestaurant::where('id', $request->voucher_id)->first(); + $voucherDetail = RedeemRestaurant::where('id', $request->voucher_id)->where('is_redeem', 1)->first(); $rest = ManageRestaurant::where('id', $voucherDetail->manage_restaurants_xid)->first(); if ($voucherDetail) { $voucherDetail->update([ diff --git a/resources/views/Admin/pages/manage_contact_us/manage_contact.blade.php b/resources/views/Admin/pages/manage_contact_us/manage_contact.blade.php index 6a4c079..dbe47b6 100644 --- a/resources/views/Admin/pages/manage_contact_us/manage_contact.blade.php +++ b/resources/views/Admin/pages/manage_contact_us/manage_contact.blade.php @@ -98,16 +98,16 @@ {{ $querie['email'] }} {{ $querie['created_at']->format('m/d/y') }} - @if ($querie->customer) - @if ($querie->customer->principal_type_xid == 3) - Customer - @else - Restaurant - @endif - @else - No category - @endif - + @if ($querie->customer) + @if ($querie->customer->principal_type_xid == 3) + Customer + @else + Restaurant + @endif + @else + No category + @endif + View - -
-
- - -
-
+ +
+
+ + +
+
+ --> @if (!$querie['is_reply'])
Delete - - @endforeach + + @endforeach
@@ -172,8 +173,7 @@ + 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 68e8b7b..aafdb0f 100644 --- a/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php +++ b/resources/views/Admin/pages/manage_restaurants/add_restaurant.blade.php @@ -109,7 +109,17 @@ -
+
+
+ + + + + +
+
+ {{--
@foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day) @@ -127,7 +137,7 @@
@endforeach
-
+ --}}
@@ -171,16 +181,7 @@
-
-
- - - - - -
-
+
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 8b89bef..bf49872 100644 --- a/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php +++ b/resources/views/Admin/pages/manage_restaurants/edit_restaurant.blade.php @@ -175,7 +175,7 @@ value="{{ $restaurantItem->try_on_4 }}">
-
+ {{--
@foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day) @@ -196,7 +196,7 @@ @endforeach
-
+
--}}