@@ -12,17 +12,42 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ManageRestrauntController extends Controller
|
||||
{
|
||||
public function index()
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
Use : To Get Restaurant Page.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$restaurant = ManageRestaurant::with('operatingHours')->latest()->get();
|
||||
$activeQuery = $request->query('active');
|
||||
if ($activeQuery == 1) {
|
||||
|
||||
$restaurant = ManageRestaurant::where('is_active', 1)->latest()->get();
|
||||
} else if ($activeQuery == 0 && $activeQuery != null) {
|
||||
$restaurant = ManageRestaurant::where('is_active', 0)->latest()->get();
|
||||
} else {
|
||||
$restaurant = ManageRestaurant::latest()->get();
|
||||
}
|
||||
return view('Admin.pages.manage_restaurants.manage_restaurants', compact('restaurant'));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
Use : To Add Restaurant Page.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
return view('Admin.pages.manage_restaurants.add_restaurant');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
Use : To store resturant form.
|
||||
*/
|
||||
public function store_restaurant(Request $request)
|
||||
{
|
||||
try {
|
||||
@@ -71,6 +96,12 @@ class ManageRestrauntController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
Use : To edit Restaurant Page.
|
||||
*/
|
||||
public function edit_restaurant(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
@@ -91,7 +122,11 @@ class ManageRestrauntController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
Use : To Update Resturant Form.
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
try {
|
||||
@@ -143,22 +178,66 @@ class ManageRestrauntController extends Controller
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
Use : To view restaurant Page.
|
||||
*/
|
||||
public function viewRestaurant(Request $request, $id)
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$restaurantItem = ManageRestaurant::where('id', $id)->first();
|
||||
$restaurantItem['image'] = ListingImageUrl('restaurant_images', $restaurantItem['image']);
|
||||
$operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week');
|
||||
|
||||
return view('Admin.pages.manage_restaurants.view_restaurant', compact('restaurantItem','operating_hours'));
|
||||
return view('Admin.pages.manage_restaurants.view_restaurant', compact('restaurantItem', 'operating_hours'));
|
||||
} catch (Exception $e) {
|
||||
Log::error("view Voucher Load Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 30 May 2024
|
||||
Use : To Update status of restaurant.
|
||||
*/
|
||||
public function updateRestaurantStatus(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$voucher_data = ManageRestaurant::where('id', $request->dataId)->first();
|
||||
$voucher_data->is_active = $request->status ?? 0;
|
||||
$voucher_data->save();
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.update_data'));
|
||||
} catch (Exception $e) {
|
||||
Log::error("Update Status function Load Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 30 May 2024
|
||||
Use : To Delete Restaurant.
|
||||
*/
|
||||
public function deleteRestaurant(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
$update = ManageRestaurant::where('id', $id)->update(['is_active' => 0]);
|
||||
$deleteRestaurant = ManageRestaurant::where('id', $id)->delete();
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.delete'));
|
||||
} catch (Exception $e) {
|
||||
Log::error("delete function Load Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- END LOADER -->
|
||||
<!-- BEGIN MAIN CONTAINER -->
|
||||
|
||||
@@ -110,9 +111,9 @@
|
||||
|
||||
<li>
|
||||
|
||||
<a href="#" id="delete_voucher_id"
|
||||
<a href="#" id="delete_restaurant_id"
|
||||
data-id="{{ $restaurants->id }}" data-toggle="modal"
|
||||
data-target="#delete-voucher-modal">
|
||||
data-target="#delete-restaurant-modal">
|
||||
<img
|
||||
src="{{ asset('public/assets/img/delete-recycle.svg') }}" />
|
||||
<span>Delete Details</span>
|
||||
@@ -134,7 +135,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="delete-voucher-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
<div class="modal fade" id="delete-restaurant-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
@@ -148,7 +149,7 @@
|
||||
<input type="hidden" id="news_delete">
|
||||
<div class="modal-btn d-flex ">
|
||||
<a class="extra-btn" href="#" data-dismiss="modal">No</a>
|
||||
<a class="download-btn-custom" id="delete_voucher" href="#" data-dismiss="modal">Yes</a>
|
||||
<a class="download-btn-custom" id="delete_restaurant" href="#" data-dismiss="modal">Yes</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -181,8 +182,165 @@
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('<button><a class="extra-btn width-max-content" href="{{ route('add_manage_restraunt') }}">Add</a></button><button><a class="extra-btn width-max-content" href="manage-restraunts-archive.php">View Archive List</a></button>')
|
||||
$('<button><a class="extra-btn width-max-content" href="{{ route('add_manage_restraunt') }}">Add</a></button><button><a class="extra-btn width-max-content" href="manage-restraunts-archive.php">View Archive List</a></button><button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-indicators avatar-online"><h3>Filter</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="{{ route('manage.restaurants') }}" id="allFilter"><span>All</span></a></div><div class="dropdown-item"><a href="{{ route('manage.restaurants', ['active' => true]) }}" id="activeFilter"><span>Active</span></a></div><div class="dropdown-item"><a href="{{ route('manage.restaurants', ['active' => false]) }}" id="expiredFilter"> <span>Expired</span></a></div></div></li></ul></button>')
|
||||
.insertBefore("#zero-config_filter label");
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#status-change input[type="checkbox"]').on('change', function() {
|
||||
var dataId = $(this).data('id');
|
||||
var isChecked = $(this).is(':checked');
|
||||
|
||||
// Perform actions based on the dataId and isChecked values
|
||||
var status = isChecked ? '1' : '0';
|
||||
updateStatusOfVoucher(status, dataId);
|
||||
if (isChecked) {
|
||||
// console.log('Switch with data-id ' + dataId + ' is checked.');
|
||||
// Perform additional logic for checked state
|
||||
} else {
|
||||
// console.log('Switch with data-id ' + dataId + ' is unchecked.');
|
||||
// Perform additional logic for unchecked state
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function updateStatusOfVoucher(status, dataId) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: "{{ route('update_status_of_restaurant') }}",
|
||||
method: 'POST',
|
||||
data: {
|
||||
status: status,
|
||||
dataId: dataId
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.status_code == 200) {
|
||||
toastr.success('Restaurant Status 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);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle errors if needed
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(function(e) {
|
||||
|
||||
$("#select-all-ids").click(function() {
|
||||
$(".form-check-input").prop('checked', $(this).prop('checked'));
|
||||
});
|
||||
|
||||
$(".form-check-input").click(function() {
|
||||
if (!$(this).prop('checked')) {
|
||||
$("#select-all-ids").prop('checked', false);
|
||||
} else {
|
||||
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
|
||||
$("#select-all-ids").prop('checked', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#download-selected').click(function(e) {
|
||||
console.log("hii");
|
||||
e.preventDefault();
|
||||
console.log("e prevendefault triggered");
|
||||
var allIds = [];
|
||||
$('input:checkbox[name=caregiver_ids]:checked').each(function() {
|
||||
allIds.push($(this).val())
|
||||
});
|
||||
$.ajax({
|
||||
url: "",
|
||||
type: "POST",
|
||||
data: {
|
||||
ids: allIds,
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
console.log("response", response);
|
||||
var downloadUrl = response.file_path;
|
||||
window.location.href = downloadUrl;
|
||||
|
||||
|
||||
|
||||
// $.each(allIds,function(key,val){
|
||||
// console.log("val",val);
|
||||
// // $('#caregiver_ids',+val).remove();
|
||||
// });
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errorMessage = xhr.responseJSON.error;
|
||||
|
||||
// Show the toast message
|
||||
toastr.error(errorMessage, 'Error', {
|
||||
timeOut: 3000
|
||||
});
|
||||
|
||||
// Show the error message to the user
|
||||
console.log("err msg", errorMessage);
|
||||
} else {
|
||||
// Handle other error cases
|
||||
console.log(xhr.responseText);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
//delete Article
|
||||
$(document).on('click', "#delete_restaurant_id", function() {
|
||||
var delete_restaurant_id = $(this).data('id');
|
||||
$("#news_delete").val(delete_restaurant_id);
|
||||
})
|
||||
|
||||
$(document).on('click', '#delete_restaurant', function(e) {
|
||||
e.preventDefault();
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
var id = $('#news_delete').val();
|
||||
console.log("id", id)
|
||||
|
||||
$('#delete_restaurant').text('Please wait...');
|
||||
$('#delete_restaurant').attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
||||
url: 'delete_restaurant/' + id,
|
||||
success: function(result) {
|
||||
if (result.status_code == 200) {
|
||||
toastr.success('Restaurant Deleted 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -5,77 +5,127 @@
|
||||
$currentPage = 'restraunt';
|
||||
@endphp
|
||||
|
||||
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
<div class="top-tabel">
|
||||
<div class="row">
|
||||
<div class="col-md-4 left">
|
||||
<a class="d-flex align-items-center justify-content-center pl-2"
|
||||
href="{{ route('manage.restaurants')}}">
|
||||
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg')}}">
|
||||
<h6 class="card-title p-0">View Details</h6>
|
||||
</a>
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
<div class="top-tabel">
|
||||
<div class="row">
|
||||
<div class="col-md-4 left">
|
||||
<a class="d-flex align-items-center justify-content-center pl-2"
|
||||
href="{{ route('manage.restaurants') }}">
|
||||
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg') }}">
|
||||
<h6 class="card-title p-0">View Details</h6>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
|
||||
<div class="widget-content widget-content-area br-8 position-btn p-0">
|
||||
<div class="view-details">
|
||||
<div class="simple-tab">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel"
|
||||
aria-labelledby="home-tab" tabindex="0">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-10 tabs23">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Restaurant Name :</td>
|
||||
<td>Restaurant ID :</td>
|
||||
<td>Bio :</td>
|
||||
<td>Monday :</td>
|
||||
<td>Tuesday :</td>
|
||||
<td>Wednesday :</td>
|
||||
<td>Thursday :</td>
|
||||
<td>Friday :</td>
|
||||
<td>Saturday :</td>
|
||||
<td>Sunday :</td>
|
||||
<td>Image :</td>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
|
||||
<div class="widget-content widget-content-area br-8 position-btn p-0">
|
||||
<div class="view-details">
|
||||
<div class="simple-tab">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel"
|
||||
aria-labelledby="home-tab" tabindex="0">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-10 tabs23">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Restaurant Name :</td>
|
||||
<td>Restaurant ID :</td>
|
||||
<td>Image :</td>
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
<td>{{$restaurantItem->name}}</td>
|
||||
<td>{{$restaurantItem->restaurant_id}}</td>
|
||||
{{-- <td height="10px" width="10px"><img src="{{$restaurantItem->image}}"></td> --}}
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="col-md-6 mb-10">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Description :</td>
|
||||
<td>Status :</td>
|
||||
<td>Address :</td>
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
<td>{!! $restaurantItem->description !!}</td>
|
||||
<td>{{$restaurantItem->is_active == 1 ? 'Active':'Expired'}}</td>
|
||||
<td >{{$restaurantItem->address}}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
<td>{{ $restaurantItem->name }}</td>
|
||||
<td>{{ $restaurantItem->restaurant_id }}</td>
|
||||
<td>{{ $restaurantItem->bio }}</td>
|
||||
@foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day)
|
||||
<td>
|
||||
{{ isset($operating_hours[$day]) ? $operating_hours[$day]->start_time . ' - ' . $operating_hours[$day]->end_time : 'N/A' }}
|
||||
</td>
|
||||
@endforeach
|
||||
<td> <div id="imageInputPreviewNormal" style="width: 30%;">
|
||||
<img src="{{ $restaurantItem->image }}" alt="Image Preview"
|
||||
style="width: 40%;">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-6 mb-10">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Description :</td>
|
||||
<td>Status :</td>
|
||||
<td>Address :</td>
|
||||
<td>Try on 1 :</td>
|
||||
<td>Try on 2 :</td>
|
||||
<td>Try on 3 :</td>
|
||||
<td>Try on 4 :</td>
|
||||
<td>Exclusion :</td>
|
||||
<td>Latitude :</td>
|
||||
<td>Longitude :</td>
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
<td>{!! $restaurantItem->description !!}</td>
|
||||
<td>{{ $restaurantItem->is_active == 1 ? 'Active' : 'Expired' }}
|
||||
</td>
|
||||
<td>{{ $restaurantItem->address }}</td>
|
||||
<td>{{ $restaurantItem->try_on_1 }}</td>
|
||||
<td>{{ $restaurantItem->try_on_2 }}</td>
|
||||
<td>{{ $restaurantItem->try_on_3 }}</td>
|
||||
<td>{{ $restaurantItem->try_on_4 }}</td>
|
||||
<td>{{ $restaurantItem->exclusion }}</td>
|
||||
<td>{{ $restaurantItem->latitude }}</td>
|
||||
<td>{{ $restaurantItem->longtitude }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('section_script')
|
||||
<script>
|
||||
|
||||
@endsection
|
||||
const imageInputEdit = document.getElementById('imageInputNormal');
|
||||
const imagePreviewEdit = document.getElementById('imageInputPreviewNormal');
|
||||
|
||||
@section('section_script')
|
||||
@endsection
|
||||
imageInputEdit.addEventListener('change', function() {
|
||||
const file = this.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
const img = document.createElement('img');
|
||||
img.src = event.target.result;
|
||||
img.style.maxWidth = '200px';
|
||||
img.style.maxHeight = '200px';
|
||||
imagePreviewEdit.innerHTML = '';
|
||||
imagePreviewEdit.appendChild(img);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
imagePreviewEdit.innerHTML = '';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -138,6 +138,10 @@ Route::post('/store_restaurant', [ManageRestrauntController::class, 'store_resta
|
||||
Route::get('/edit_restaurant/{id}', [ManageRestrauntController::class, 'edit_restaurant'])->name('edit_restaurant');
|
||||
Route::post('/update_restaurant', [ManageRestrauntController::class, 'update'])->name('update_restaurant');
|
||||
Route::get('/manage_view_restaurant/{id}', [ManageRestrauntController::class, 'viewRestaurant'])->name('manage_view_restaurant');
|
||||
Route::post('/update_status_of_restaurant', [ManageRestrauntController::class, 'updateRestaurantStatus'])->name('update_status_of_restaurant');
|
||||
Route::post('/delete_restaurant/{id}', [ManageRestrauntController::class, 'deleteRestaurant'])->name('delete_restaurant');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user