update restaurant
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -165,4 +165,9 @@
|
||||
allowClear: true
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
var quill = new Quill('#news-quill-add', {
|
||||
theme: 'snow'
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -4,6 +4,20 @@
|
||||
@php
|
||||
$currentPage = 'restraunt';
|
||||
@endphp
|
||||
<style>
|
||||
.error-message {
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
form .error-message {
|
||||
color: red;
|
||||
/* Set your desired color here */
|
||||
}
|
||||
|
||||
form .input_class.error-message {
|
||||
color: #0e1726;
|
||||
}
|
||||
</style>
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
@@ -37,19 +51,18 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<div class="form-group">
|
||||
<label for="company-name" class="label">Description</label>
|
||||
<div id="rest-quill-edit" class="editor-quill" style="height: 100px;">
|
||||
{!! $restaurantItem->description !!}</div>
|
||||
<input type="hidden" id="description" name="description"
|
||||
value="{{ $restaurantItem->description }}">
|
||||
<textarea type="text" class="form-control" name="description">{!! $restaurantItem->description !!}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label for="company-name" class="label">Restaurant ID</label>
|
||||
<input type="text" class="form-control" id="restaurant_id" name="restaurant_id"
|
||||
maxlength="30" value="{{ $restaurantItem->restaurant_id }}">
|
||||
<input type="text" class="form-control" id="restaurant_id"
|
||||
name="restaurant_id" maxlength="30"
|
||||
value="{{ $restaurantItem->restaurant_id }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@@ -67,8 +80,28 @@
|
||||
<div class="form-group ">
|
||||
<label for="company-name" class="label">Restaurant Location</label>
|
||||
<input type="text" class="form-control" id="location_name"
|
||||
name="location_name" value="{{ $restaurantItem->address }}"
|
||||
maxlength="100">
|
||||
name="location_name" value="{{ $restaurantItem->address }}" maxlength="100">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label for="company-name" class="label">Exclusion</label>
|
||||
<input type="text" class="form-control" id="exclusion" name="exclusion"
|
||||
maxlength="30" value="{{ $restaurantItem->exclusion }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label for="company-name" class="label">Latitude</label>
|
||||
<input type="text" class="form-control" id="latitude" name="latitude"
|
||||
maxlength="30" value="{{ $restaurantItem->latitude }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label for="company-name" class="label">Longitude</label>
|
||||
<input type="text" class="form-control" id="longitude" name="longitude"
|
||||
maxlength="30" value="{{ $restaurantItem->longtitude }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@@ -90,13 +123,32 @@
|
||||
value="{{ $restaurantItem->try_on_3 }}">
|
||||
<input type="text" class="form-control mb-3" name="try_on_4"
|
||||
value="{{ $restaurantItem->try_on_4 }}">
|
||||
<input type="text" class="form-control mb-3" name="try_on_5"
|
||||
value="{{ $restaurantItem->try_on_5 }}">
|
||||
</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)
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<label>{{ $day }} Start Time:</label>
|
||||
<input type="time" class="form-control"
|
||||
name="operating_hours[{{ $day }}][start_time]"
|
||||
value="{{ isset($operating_hours[$day]) ? $operating_hours[$day]->start_time : '' }}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label>{{ $day }} End Time:</label>
|
||||
<input type="time" class="form-control"
|
||||
name="operating_hours[{{ $day }}][end_time]"
|
||||
value="{{ isset($operating_hours[$day]) ? $operating_hours[$day]->end_time : '' }}">
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button class="download-btn "style="width: 30%;" id="update_coupon">
|
||||
<button class="download-btn "style="width: 30%;" id="update_restaurant">
|
||||
<span>Submit</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -155,11 +207,133 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@endsection
|
||||
@section('section_script')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#update_voucher').validate({
|
||||
ignore: [],
|
||||
debug: false,
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
},
|
||||
description: {
|
||||
required: true,
|
||||
},
|
||||
rest_id: {
|
||||
required: true,
|
||||
},
|
||||
address: {
|
||||
required: true,
|
||||
},
|
||||
exclusion: {
|
||||
required: true,
|
||||
},
|
||||
latitude: {
|
||||
required: true,
|
||||
},
|
||||
longitude: {
|
||||
required: true,
|
||||
},
|
||||
bio: {
|
||||
required: true,
|
||||
},
|
||||
try_on_1: {
|
||||
required: true,
|
||||
},
|
||||
try_on_2: {
|
||||
required: true,
|
||||
},
|
||||
try_on_3: {
|
||||
required: true,
|
||||
},
|
||||
try_on_4: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
name: {
|
||||
required: "Enter restaurant Name",
|
||||
},
|
||||
description: {
|
||||
required: "Enter Description",
|
||||
},
|
||||
rest_id: {
|
||||
required: "Enter restaurant Id",
|
||||
},
|
||||
address: {
|
||||
required: "Please enter location",
|
||||
},
|
||||
exclusion: {
|
||||
required: "Please enter exclusion",
|
||||
},
|
||||
latitude: {
|
||||
required: "Please enter latitude",
|
||||
},
|
||||
longitude: {
|
||||
required: "Please enter longitude",
|
||||
},
|
||||
bio: {
|
||||
required: "Enter Bio",
|
||||
},
|
||||
try_on_1: {
|
||||
required: "Please enter this field",
|
||||
},
|
||||
try_on_2: {
|
||||
required: "Please enter this field",
|
||||
},
|
||||
try_on_3: {
|
||||
required: "Please enter this field",
|
||||
},
|
||||
try_on_4: {
|
||||
required: "Please enter this field",
|
||||
},
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
submitHandler: function(form) {
|
||||
var formData = new FormData(form);
|
||||
|
||||
$('#update_restaurant').text('Please wait...');
|
||||
$('#update_restaurant').attr('disabled', true);
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: "{{ route('update_restaurant') }}",
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(result) {
|
||||
|
||||
if (result.status_code == 200) {
|
||||
toastr.success('Restaurant Updated Sucessfully');
|
||||
setTimeout(function() {
|
||||
window.location.href =
|
||||
"{{ route('manage.restaurants') }}";
|
||||
}, 2000);
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function() {
|
||||
window.location.href =
|
||||
"{{ route('manage.restaurants') }}";
|
||||
}, 2000);
|
||||
}
|
||||
$('#update_restaurant').attr('disabled', false);
|
||||
$('#update_restaurant').text('Submit');
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
$('#store_coupon').attr('disabled', false);
|
||||
$('#store_coupon').text('Submit');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user