/
var
/
www
/
html
/
cravings
/
storage
/
framework
/
views
/
Upload File
HOME
<?php $__env->startSection('style'); ?> ##parent-placeholder-26ec8d00fb6b55466b3a115f1d559422a7fa7aac## <style> .form-check .form-check-label { padding-right: 5px; } .table { table-layout: fixed; } </style> <?php $__env->stopSection(); ?> <?php $__env->startSection('content'); ?> <div class="row"> </div> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-body"> <h4>Food categories for <?php echo e($place['name']); ?></h4> <a class="btn btn-warning" href="<?php echo e(route('add_place_categories', ['slug' => $place['slug']])); ?>"> <i class="fa fa-arrow-left"></i> Add Categories</a> <div class="table-responsive"> <table class="table"> <thead class="text-primary"> <tr> <th>Name</th> <th>Price</th> <th>Description</th> <th>Categories</th> <th>Actions</th> </tr> </thead> <tbody> <?php $__currentLoopData = $place['food']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $food): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <tr> <td> <?php echo e($food['name']); ?> </td> <td><?php echo e($food['price']); ?></td> <td><?php echo e($food['description']); ?></td> <td> <?php $__currentLoopData = $place['category']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <?php $id = $food['_id'] . '-' . $loop->index; ?> <div class="form-check form-check-inline"> <label for="<?php echo e($id); ?>" class="form-check-label"><?php echo e($category); ?></label> <input type="radio" id="<?php echo e($id); ?>" name="<?php echo e($food['_id']); ?>" value="<?php echo e($category); ?>" class="form-check-input food-category" <?php echo e(isset($food['category']) && $food['category'] == $category ? 'checked' : ''); ?>> </div> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> <div class="form-check form-check-inline"> <label for="none" class="form-check-label">None</label> <input type="radio" id="none" name="<?php echo e($food['_id']); ?>" value="" class="form-check-input food-category" <?php echo e(!isset($food['category']) || !$food['category'] ? 'checked' : ''); ?>> </div> </td> <td> <a href="#" class="delete-food" data-id="<?php echo e($food['_id']); ?>" data-name="<?php echo e($food['name'] ?? ''); ?>"> Delete </a> </td> </tr> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </tbody> </table> </div> </div> </div> </div> </div> <?php $__env->stopSection(); ?> <?php $__env->startSection('scripts'); ?> <script> const headers = { 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('value'), 'X-Requested-With': 'XMLHttpRequest' } $('.delete-food').on('click', function(e){ e.preventDefault(); const $target = $(e.currentTarget); const _id = $target.data('id'); const name = $target.data('name'); fetch(`/admin/food/delete/${_id}`, {credentials: 'same-origin', method: 'DELETE', headers}) .then(response => response.json()) .then(result => { console.log(result) $target.closest('tr').fadeOut(300, function(){ $(this).remove(); }) // if(result.status === 'success'){ // } }).catch(error => console.error(error)) }); document.querySelectorAll('.food-category').forEach(radio => { radio.addEventListener('change', function(e){ fetch('/admin/food/category', { method: 'PATCH', body: JSON.stringify({category: e.target.value, id: e.target.getAttribute('name')}), headers }).then(response => response.json()) .then(({status}) => console.log(status)) }) }); </script> <?php $__env->stopSection(); ?> <?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/cravings/resources/views/admin/place_food.blade.php ENDPATH**/ ?>