|
6 | 6 | @include('layouts.alert')
|
7 | 7 | @push('scripts')
|
8 | 8 | <script>
|
9 |
| - $('.delete-airport').on('click', function (e) { |
| 9 | + $('.delete-airport').on('click', function(e) { |
10 | 10 | e.preventDefault();
|
11 | 11 | Swal.fire({
|
12 | 12 | title: 'Are you sure',
|
|
21 | 21 | }
|
22 | 22 | });
|
23 | 23 | });
|
| 24 | + $('.delete-unused-airports').on('click', function(e) { |
| 25 | + e.preventDefault(); |
| 26 | + Swal.fire({ |
| 27 | + title: 'Are you sure', |
| 28 | + text: 'Are you sure you want to delete all unused airports?', |
| 29 | + icon: 'warning', |
| 30 | + showCancelButton: true, |
| 31 | + }).then((result) => { |
| 32 | + if (result.value) { |
| 33 | + Swal.fire('Deleting unused airports...'); |
| 34 | + Swal.showLoading(); |
| 35 | + $(`#${$(this).attr('form')}`).submit(); |
| 36 | + } |
| 37 | + }); |
| 38 | + }); |
24 | 39 | </script>
|
25 | 40 | @endpush
|
26 | 41 | <p>
|
27 | 42 | <a href="{{ route('admin.airports.create') }}" class="btn btn-primary"><i class="fa fa-plus"></i> Add new
|
28 | 43 | Airport</a>
|
29 |
| - <a href=" {{ route('admin.airportLinks.create') }}" class="btn btn-primary"><i class="fa fa-plus"></i> Add new |
| 44 | + <a href="{{ route('admin.airportLinks.create') }}" class="btn btn-primary"><i class="fa fa-plus"></i> Add new |
30 | 45 | Airport
|
31 | 46 | Link</a>
|
| 47 | + <button class="btn btn-danger delete-unused-airports" form="delete-unused-airports"><i class="fa fa-trash"></i> |
| 48 | + Delete unused airports</button> |
32 | 49 | </p>
|
33 | 50 | <table class="table table-hover">
|
34 | 51 | <thead>
|
35 |
| - <tr> |
36 |
| - <th scope="row">ICAO</th> |
37 |
| - <th scope="row">IATA</th> |
38 |
| - <th scope="row">Name</th> |
39 |
| - <th scope="row" colspan="2">Actions</th> |
40 |
| - </tr> |
| 52 | + <tr> |
| 53 | + <th scope="row">ICAO</th> |
| 54 | + <th scope="row">IATA</th> |
| 55 | + <th scope="row">Name</th> |
| 56 | + <th scope="row" colspan="2">Actions</th> |
| 57 | + </tr> |
41 | 58 | </thead>
|
42 | 59 | @forelse($airports as $airport)
|
43 | 60 | <tr>
|
|
52 | 69 | </a>
|
53 | 70 | </td>
|
54 | 71 | <td>
|
55 |
| - @if($airport->flightsDep->isEmpty() && $airport->flightsArr->isEmpty() && $airport->eventDep->isEmpty() && $airport->eventArr->isEmpty()) |
| 72 | + @if ($airport->flightsDep->isEmpty() && $airport->flightsArr->isEmpty() && $airport->eventDep->isEmpty() && $airport->eventArr->isEmpty()) |
56 | 73 | <form action="{{ route('admin.airports.destroy', $airport) }}" method="post">
|
57 | 74 | @method('DELETE')
|
58 | 75 | <button class="btn btn-danger delete-airport"><i class="fa fa-trash"></i> Remove Airport
|
|
74 | 91 | {{ $airports->links() }}
|
75 | 92 | </table>
|
76 | 93 | {{ $airports->links() }}
|
| 94 | + <x-form :action="route('admin.airports.destroyUnused')" id="delete-unused-airports" method="POST" |
| 95 | + style="display: none;"></x-form> |
77 | 96 | @endsection
|
0 commit comments