/
home
/
obinna
/
html
/
cravings
/
resources
/
views
/
admin
/
Upload File
HOME
@extends('layouts.admin') @section('content') <div class="row"> @if(isset($user)) <div class="col-md-4"> <div class="card card-user"> <!-- <div class="image"> <img src="/admin-assets/img/damir-bosnjak.jpg" alt="..."> </div> --> <div class="card-body"> <div class="author" style="margin-top:0;"> <a href="#"> <!-- <img class="avatar border-gray" src="../assets/img/mike.jpg" alt="..."> --> <h5 class="title">{{ $user['name'] }}</h5> </a> <p class="description"> {{ $user['email'] }} </p> </div> </div> <div class="card-footer"> <hr> <div class="button-container"> <div class="row"> <div class="col-lg-3 col-md-6 col-6 ml-auto"> <h5>{{ $count }} <br> <small>Places</small> </h5> </div> <div class="col-lg-4 col-md-6 col-6 ml-auto mr-auto"> <h5>{{ $foodCount }} <br> <small>Food</small> </h5> </div> <!-- <div class="col-lg-3 mr-auto"> <h5>24,6$ <br> <small>Spent</small> </h5> </div> --> </div> </div> </div> </div> </div> @endif </div> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <h4 class="card-title">Places ({{ count($places) }})</h4> </div> <div class="card-body"> <div class="table-responsive"> <table class="table"> <thead class="text-primary"> <tr> <th>Name</th> <th>Address</th> <th>Phone 1</th> <th>Phone 2</th> <th>Opening</th> <th>Closing</th> <th>Longitude</th> <th>Latitude</th> <th>Actions</th> </tr> </thead> <tbody> @php $types = [ 'restaurant' => 'Restaurant', 'mamaput' => 'Mama Put', 'bar' => 'Bar', 'streetfood' => 'Street Food', 'fastfood' => 'Fast Food', 'hotel' => 'Hotel', 'fast' => 'Fast Food', 'eatery' => 'Eatery', 'cafe' => 'Cafe', 'online' => 'Delivery Only' ]; $cats = [ 'african' => 'African', 'continental' => 'Continental', 'chinese' => 'Chinese', 'indian' => 'Indian', 'fastfood' => 'FastFood', 'breakfast' => 'Breakfast', 'finedining' => 'FineDining', 'healthy' => 'Healthy', 'grill' => 'Grill', 'parking' => 'Parking', 'seating' => 'Seating', 'delivery' => 'Delivery' ] @endphp @if($places) @foreach($places as $place) <tr> <td> <a href="{{ route('places.show', ['slug' => $place['slug']]) }}"> {{ isset($place['name']) ? $place['name'] : "" }} </a> </td> <td>{{ isset($place['address']) ? $place['address'] : "" }}</td> <td>{{ isset($place['phones'][0]) ? $place['phones'][0] : "" }}</td> <td>{{ isset($place['phones'][1]) ? $place['phones'][1] : "" }}</td> <td>{{ isset($place['opening']) ? $place['opening'] : "" }}</td> <td>{{ isset($place['closing']) ? $place['closing'] : "" }}</td> <td>{{ isset($place['location']) && isset($place['location']['coordinates']) ? $place['location']['coordinates'][0] : "" }}</td> <td>{{ isset($place['location']) && isset($place['location']['coordinates']) ? $place['location']['coordinates'][1] : "" }}</td> <td> @if(isset($place['image']) && is_array($place['image'])) @foreach($place['image'] as $image) <div> <a href="{{ $image }}" target="_blank"><img src="{{ $image }}" alt="{{ $place['name'] }}" /></a><a class="delete-picture" href="{{ route('delete_place_picture', ['slug' => $place['slug'], 'index' => $loop->index])}}"><i class="fa fa-trash"></i></a> </div> @endforeach @endif </td> <td> <a href="{{ route('edit_place', ['id' => $place['slug']])}}" target="_blank">Edit</a> | <a data-slug="{{ $place['slug'] }}" href="{{ route('admin_places_delete_lockdown', ['slug' => $place['slug']])}}" class="delete-one">Delete</a> </td> </tr> <tr> <td colspan="10"> @if(isset($place['food'])) @foreach($place['food'] as $food) <span class="badge badge-warning"> {{ $food['name'] }} - {{ $food['price'] }} <a href="#" class=" delete-food" data-id="{{ $food['_id'] }}" data-name="{{ $food['name'] }}"> <i class="fa fa-times"></i> </a> </span> @endforeach @endif </td> </tr> @endforeach @else <tr> <td colspan="10" class="text-center">No Places</td> </tr> @endif </tbody> </table> </div> </div> </div> </div> </div> @endsection @section('scripts') <script> $('.delete-food').on('click', function(e){ e.preventDefault(); const $target = $(e.currentTarget); const _id = $target.data('id'); const name = $target.data('name'); var con = confirm('Are you sure you want to delete ' + name); if(con){ fetch(`/admin/food/delete/${_id}`, {credentials: 'same-origin'}) .then(response => response.json()) .then(result => { console.log(result) $target.closest('.badge').fadeOut(300, function(){ $(this).remove(); }) // if(result.status === 'success'){ // } }).catch(error => console.log(error)) }else { console.log('no') } }); const gotohref = (e) => { e.preventDefault() const $target = $(e.currentTarget); // const id = $target.data('id'); const link = $target.attr('href'); return fetch(link, {credentials: 'same-origin', method: 'DELETE', headers: { 'X-CSRF-Token': $('meta[name="_token"]').attr('content') } } ).then(response => response.json()) } $('.delete-one').on('click', function(e){ const $target = $(e.currentTarget); gotohref(e).then(response => { console.log(response) const $row = $target.closest('tr') $row.fadeOut(); $row.next().fadeOut(); }).catch(error => console.log(error)) }) $('.delete-picture').on('click', function(e){ const $target = $(e.currentTarget); gotohref(e).then(response => { const $row = $target.closest('div') $row.fadeOut(); // $row.next().fadeOut(); }) }) </script> @endsection