107 lines
5.4 KiB
PHP
107 lines
5.4 KiB
PHP
@extends('layouts.admin')
|
||
@section('content')
|
||
<h1>Города</h1>
|
||
|
||
<div class="d-flex mb-3">
|
||
<form class="p-2 border rounded-3 border-1 bg-white" method="GET" action="{{ route('admin.cities') }}">
|
||
<input type="radio" class="btn-check" name="filter" value="all" id="option_all" autocomplete="off"
|
||
onclick="this.form.submit()" {{ $filter == 'all' || !$filter ? 'checked' : '' }}>
|
||
<label class="btn p-2 fs-5" for="option_all">Все</label>
|
||
|
||
<input type="radio" class="btn-check" name="filter" value="actual" id="option_actual" autocomplete="off"
|
||
onclick="this.form.submit()" {{ $filter == 'actual' ? 'checked' : '' }}>
|
||
<label class="btn p-2 fs-5" for="option_actual">Актуальные</label>
|
||
|
||
<input type="radio" class="btn-check" name="filter" value="trashed" id="option_trashed" autocomplete="off"
|
||
onclick="this.form.submit()" {{ $filter == 'trashed' ? 'checked' : '' }}>
|
||
<label class="btn p-2 fs-5" for="option_trashed">Удаленные</label>
|
||
</form>
|
||
|
||
|
||
<div class="ms-auto p-2">
|
||
<button class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal" data-bs-target="#createCityModal">
|
||
<i class="bi bi-plus"></i> Добавить город
|
||
</button>
|
||
</div>
|
||
</div>
|
||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||
<table class="table m-0">
|
||
<thead>
|
||
<tr scope="col">
|
||
<th>Название</th>
|
||
<th>Дата создания</th>
|
||
<th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class=" ">
|
||
@foreach ($cities as $city)
|
||
<tr scope="row" class="@if ($city->trashed()) bg-secondary @endif">
|
||
<td class="align-middle">
|
||
{{ $city->name }}
|
||
</td>
|
||
<td>
|
||
{{ $city->created_at ? $city->created_at->diffForHumans() : '' }}
|
||
</td>
|
||
<td class="text-end">
|
||
<div class="dropdown" style="">
|
||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||
@if ($city->trashed())
|
||
<i class="bi bi-recycle"></i>
|
||
@else
|
||
<i class="bi bi-three-dots-vertical"></i>
|
||
@endif
|
||
</button>
|
||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||
@if ($city->trashed())
|
||
<form method="post"
|
||
action="{{ route('admin.cities.restore', ['city' => $city]) }}">
|
||
@csrf
|
||
<button class="dropdown-item" type="submit">Восстановить</button>
|
||
</form>
|
||
@else
|
||
<a class="dropdown-item"
|
||
href="{{ route('admin.cities.edit', ['city' => $city]) }}">Редактировать</a>
|
||
<form method="post" action="{{ route('admin.cities.delete', ['city' => $city]) }}">
|
||
@csrf
|
||
<button class="dropdown-item" type="submit">Удалить</button>
|
||
</form>
|
||
@endif
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<!-- Modal -->
|
||
<div class="modal fade" id="createCityModal" tabindex="-1" aria-labelledby="createCityModalLabel" aria-hidden="true">
|
||
|
||
<form class="modal-dialog modal-dialog-centered" action="{{ route('admin.cities.create') }}" method="post">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h1 class="modal-title fs-5" id="createCityModalLabel">Новый город</h1>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="my-3">
|
||
@csrf
|
||
<label for="cityNameInput" class="form-label">Введите название нового города</label>
|
||
<input class="form-control" type="text" id="cityNameInput" name="name" required>
|
||
@error('text')
|
||
<div class="text-danger">{{ $message }}</div>
|
||
@enderror
|
||
</div>
|
||
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="btn btn-primary">Добавить</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
@endsection
|