This commit is contained in:
Hritikkk9
2024-07-17 13:02:52 +05:30
7 changed files with 147 additions and 82 deletions

View File

@@ -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',

View File

@@ -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();

View File

@@ -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);
}
}
}

View File

@@ -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([

View File

@@ -98,16 +98,16 @@
<td class="text-start">{{ $querie['email'] }}</td>
<td class="text-start">{{ $querie['created_at']->format('m/d/y') }}</td>
<td class="text-start">
@if ($querie->customer)
@if ($querie->customer->principal_type_xid == 3)
Customer
@else
Restaurant
@endif
@else
No category
@endif
</td>
@if ($querie->customer)
@if ($querie->customer->principal_type_xid == 3)
Customer
@else
Restaurant
@endif
@else
No category
@endif
</td>
<td>
<a class="view-btn m-0" href="#" data-toggle="modal"
@@ -115,21 +115,22 @@
data-message="{{ $querie['message'] }}">View</a>
</td>
<td class="text-center">
<form>
<div class="switch-btn" id="status-change">
<input type="checkbox" id="switch{{ $querie['id'] }}" switch="bool"
data-id="{{ $querie['id'] }}" name="status" value="1"
{{ $querie['is_reply'] ? 'checked' : '' }} disabled />
<label for="switch{{ $querie['id'] }}" data-on-label="Resolved" data-off-label="Pending"></label>
</div>
</form>
<form>
<div class="switch-btn" id="status-change">
<input type="checkbox" id="switch{{ $querie['id'] }}" switch="bool"
data-id="{{ $querie['id'] }}" name="status" value="1"
{{ $querie['is_reply'] ? 'checked' : '' }} disabled />
<label for="switch{{ $querie['id'] }}" data-on-label="Resolved"
data-off-label="Pending"></label>
</div>
</form>
</td>
<td>
<!-- <div class="dropout">
</div> -->
</div> -->
@if (!$querie['is_reply'])
<div class="action-buttons">
<a href="#" class="action-btn reply-button" data-toggle="modal"
@@ -159,8 +160,8 @@
<img src="{{ asset('public/assets/img/delete-recycle.svg') }}" />
<span>Delete</span>
</a>
</tr>
@endforeach
</tr>
@endforeach
</table>
</div>
@@ -172,8 +173,7 @@
<div class="modal-body">
<div class="modal-header">
<h5 class="modal-title" id="viewMessageModalLabel">Message</h5>
<button type="button" class="close" data-dismiss="mo
dal" aria-label="Close">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
@@ -229,7 +229,7 @@
<div class="col-xxl-12">
<p><span id="reply-message"></span></p>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -109,7 +109,17 @@
<input type="text" class="form-control" name="bio" required>
</div>
</div>
<div class="col-md-12">
<div class="col-md-6">
<div class="form-group">
<label for="company-name" class="label">While at Restaurant be sure to
try:</label>
<input type="text" class="form-control mb-3" name="try_on_1" required>
<input type="text" class="form-control mb-3" name="try_on_2" required>
<input type="text" class="form-control mb-3" name="try_on_3" required>
<input type="text" class="form-control mb-3" name="try_on_4" required>
</div>
</div>
{{-- <div class="col-md-12">
<div class="form-group">
<label class="label">Operating Hours</label>
@foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day)
@@ -127,7 +137,7 @@
</div>
@endforeach
</div>
</div>
</div> --}}
<div class="col-md-6">
<div class="form-group">
<label for="closed_date" class="label">Date for Close Restaurant</label>
@@ -171,16 +181,7 @@
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="company-name" class="label">While at Restaurant be sure to
try:</label>
<input type="text" class="form-control mb-3" name="try_on_1" required>
<input type="text" class="form-control mb-3" name="try_on_2" required>
<input type="text" class="form-control mb-3" name="try_on_3" required>
<input type="text" class="form-control mb-3" name="try_on_4" required>
</div>
</div>
<div class="col-md-12">
<button id="update_restaurant_btn" type="submit"
class="download-btn-custom mt-3 custom-width-10">Save</button>

View File

@@ -175,7 +175,7 @@
value="{{ $restaurantItem->try_on_4 }}">
</div>
</div>
<div class="col-md-12">
{{-- <div class="col-md-12">
<div class="form-group">
<label class="label">Operating Hours</label>
@foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day)
@@ -196,7 +196,7 @@
@endforeach
</div>
</div>
</div> --}}
<div class="col-md-6">
<div class="form-group">
<label for="closed_date" class="label">Date for Close Restaurant</label>