This commit is contained in:
sayliraut
2024-07-17 12:21:56 +05:30
parent b5e6af1005
commit fde8df31e8
3 changed files with 46 additions and 45 deletions

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

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>