add tps
This commit is contained in:
parent
622e7e6e8c
commit
81a0553379
|
|
@ -7,6 +7,7 @@
|
|||
use App\Models\LokasiTps;
|
||||
use App\Models\KategoriTps;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class TpsController extends Controller
|
||||
{
|
||||
|
|
@ -22,7 +23,7 @@ public function index(Request $request)
|
|||
->when($search, function ($query) use ($search) {
|
||||
$query->where('nama_tps', 'like', '%' . $search . '%');
|
||||
})
|
||||
->orderBy('id_tps', 'desc') // supaya data terbaru muncul di atas
|
||||
->orderBy('id_tps', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
return view('admin.tps.index', compact('title', 'tps', 'search'));
|
||||
|
|
@ -33,6 +34,7 @@ public function create()
|
|||
{
|
||||
$title = 'Tambah TPS';
|
||||
$kategori = KategoriTps::all();
|
||||
|
||||
return view('admin.tps.create', compact('title', 'kategori'));
|
||||
}
|
||||
|
||||
|
|
@ -55,9 +57,12 @@ private function convertToDecimal($coordinate)
|
|||
if (!$dir || count($numbers[0]) < 3) return null;
|
||||
|
||||
[$deg, $min, $sec] = array_map('floatval', $numbers[0]);
|
||||
|
||||
$decimal = $deg + ($min / 60) + ($sec / 3600);
|
||||
|
||||
if (in_array($dir[1], ['S', 'W'])) $decimal *= -1;
|
||||
if (in_array($dir[1], ['S', 'W'])) {
|
||||
$decimal *= -1;
|
||||
}
|
||||
|
||||
return $decimal;
|
||||
}
|
||||
|
|
@ -78,25 +83,6 @@ public function store(Request $request)
|
|||
'longitude' => 'required',
|
||||
'foto_tps' => 'required|image|mimes:jpg,jpeg,png|max:2048',
|
||||
|
||||
], [
|
||||
|
||||
'kategori_tps_id.required' => 'Kategori TPS wajib dipilih.',
|
||||
'kategori_tps_id.exists' => 'Kategori TPS tidak valid.',
|
||||
'nama_tps.required' => 'Nama TPS wajib diisi.',
|
||||
'alamat_tps.required' => 'Alamat TPS wajib diisi.',
|
||||
'status_tps.required' => 'Status TPS wajib dipilih.',
|
||||
'status_tps.in' => 'Status TPS tidak valid.',
|
||||
'tahun_pembuatan.required' => 'Tahun pembuatan wajib diisi.',
|
||||
'tahun_pembuatan.digits' => 'Tahun pembuatan harus 4 digit.',
|
||||
'kapasitas_tps.required' => 'Kapasitas TPS wajib diisi.',
|
||||
'kapasitas_tps.integer' => 'Kapasitas TPS harus angka.',
|
||||
'kapasitas_tps.min' => 'Kapasitas minimal 1.',
|
||||
'latitude.required' => 'Latitude wajib diisi.',
|
||||
'longitude.required' => 'Longitude wajib diisi.',
|
||||
'foto_tps.required' => 'Foto TPS wajib diunggah.',
|
||||
'foto_tps.image' => 'Foto TPS harus berupa gambar.',
|
||||
'foto_tps.mimes' => 'Format foto harus jpg, jpeg, atau png.',
|
||||
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
|
@ -125,14 +111,8 @@ public function store(Request $request)
|
|||
|
||||
if ($request->hasFile('foto_tps')) {
|
||||
|
||||
$file = $request->file('foto_tps');
|
||||
|
||||
$filename = strtolower(str_replace(' ', '_', $request->nama_tps))
|
||||
. '_' . time() . '.' . $file->getClientOriginalExtension();
|
||||
|
||||
$file->move(public_path('assets/admin/images/tps'), $filename);
|
||||
|
||||
$foto = $filename;
|
||||
$foto = $request->file('foto_tps')
|
||||
->store('tps', 'public');
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -216,18 +196,12 @@ public function update(Request $request, $id)
|
|||
|
||||
if ($request->hasFile('foto_tps')) {
|
||||
|
||||
if ($tps->foto_tps && file_exists(public_path('assets/admin/images/tps/' . $tps->foto_tps))) {
|
||||
unlink(public_path('assets/admin/images/tps/' . $tps->foto_tps));
|
||||
if ($tps->foto_tps) {
|
||||
Storage::disk('public')->delete($tps->foto_tps);
|
||||
}
|
||||
|
||||
$file = $request->file('foto_tps');
|
||||
|
||||
$filename = strtolower(str_replace(' ', '_', $request->nama_tps))
|
||||
. '_' . time() . '.' . $file->getClientOriginalExtension();
|
||||
|
||||
$file->move(public_path('assets/admin/images/tps'), $filename);
|
||||
|
||||
$foto = $filename;
|
||||
$foto = $request->file('foto_tps')
|
||||
->store('tps', 'public');
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -256,19 +230,12 @@ public function destroy($id)
|
|||
|
||||
$tps = LokasiTps::findOrFail($id);
|
||||
|
||||
$fotoPath = $tps->foto_tps
|
||||
? public_path('assets/admin/images/tps/' . $tps->foto_tps)
|
||||
: null;
|
||||
|
||||
|
||||
if ($fotoPath && file_exists($fotoPath)) {
|
||||
unlink($fotoPath);
|
||||
if ($tps->foto_tps) {
|
||||
Storage::disk('public')->delete($tps->foto_tps);
|
||||
}
|
||||
|
||||
|
||||
$tps->delete();
|
||||
|
||||
|
||||
return redirect()->route('admin.tps.index')
|
||||
->with('success', 'Data TPS berhasil dihapus.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-12 grid-margin stretch-card">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
|
@ -13,95 +14,126 @@
|
|||
<p class="card-description">Form edit data kategori TPS</p>
|
||||
|
||||
<form action="{{ route('admin.kategori.update', $kategori->id_kategori_tps) }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data">
|
||||
method="POST"
|
||||
enctype="multipart/form-data">
|
||||
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
{{-- NAMA KATEGORI --}}
|
||||
<div class="form-group">
|
||||
<label>Nama Kategori</label>
|
||||
|
||||
<input type="text"
|
||||
name="nama_kategori"
|
||||
class="form-control @error('nama_kategori') is-invalid @enderror"
|
||||
value="{{ old('nama_kategori', $kategori->nama_kategori) }}"
|
||||
required>
|
||||
name="nama_kategori"
|
||||
class="form-control @error('nama_kategori') is-invalid @enderror"
|
||||
value="{{ old('nama_kategori', $kategori->nama_kategori) }}"
|
||||
required>
|
||||
|
||||
@error('nama_kategori')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
|
||||
{{-- KEPANJANGAN --}}
|
||||
<div class="form-group">
|
||||
<label>Kepanjangan Kategori</label>
|
||||
|
||||
<input type="text"
|
||||
name="kepanjangan_kategori"
|
||||
class="form-control @error('kepanjangan_kategori') is-invalid @enderror"
|
||||
value="{{ old('kepanjangan_kategori', $kategori->kepanjangan_kategori) }}">
|
||||
name="kepanjangan_kategori"
|
||||
class="form-control @error('kepanjangan_kategori') is-invalid @enderror"
|
||||
value="{{ old('kepanjangan_kategori', $kategori->kepanjangan_kategori) }}">
|
||||
|
||||
@error('kepanjangan_kategori')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
|
||||
{{-- DESKRIPSI --}}
|
||||
<div class="form-group">
|
||||
<label>Deskripsi</label>
|
||||
|
||||
<textarea name="deskripsi"
|
||||
rows="6"
|
||||
class="form-control @error('deskripsi') is-invalid @enderror"
|
||||
placeholder="Deskripsi">{{ old('deskripsi', $kategori->deskripsi) }}</textarea>
|
||||
rows="6"
|
||||
class="form-control @error('deskripsi') is-invalid @enderror"
|
||||
placeholder="Deskripsi">{{ old('deskripsi', $kategori->deskripsi) }}</textarea>
|
||||
|
||||
@error('deskripsi')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
|
||||
{{-- FOTO --}}
|
||||
<div class="form-group">
|
||||
|
||||
<label>Foto Kategori</label>
|
||||
|
||||
<!-- INPUT FILE ASLI -->
|
||||
<!-- INPUT FILE -->
|
||||
<input type="file"
|
||||
name="foto_kategori"
|
||||
id="foto_kategori"
|
||||
class="file-upload-default @error('foto_kategori') is-invalid @enderror"
|
||||
accept="image/*">
|
||||
name="foto_kategori"
|
||||
id="foto_kategori"
|
||||
class="file-upload-default @error('foto_kategori') is-invalid @enderror"
|
||||
accept="image/*">
|
||||
|
||||
|
||||
<!-- INPUT DISPLAY -->
|
||||
<div class="input-group col-xs-12">
|
||||
|
||||
<input type="text"
|
||||
class="form-control file-upload-info"
|
||||
disabled
|
||||
placeholder="Upload Foto">
|
||||
class="form-control file-upload-info"
|
||||
disabled
|
||||
placeholder="Upload Foto">
|
||||
|
||||
<span class="input-group-append">
|
||||
<button class="file-upload-browse btn btn-primary" type="button">
|
||||
<button class="file-upload-browse btn btn-primary"
|
||||
type="button">
|
||||
Upload
|
||||
</button>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
@error('foto_kategori')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
|
||||
{{-- PREVIEW FOTO LAMA --}}
|
||||
|
||||
{{-- PREVIEW FOTO --}}
|
||||
@if ($kategori->foto_kategori)
|
||||
<div class="mt-2">
|
||||
<img src="{{ asset('assets/admin/images/kategori-tps/' . $kategori->foto_kategori) }}"
|
||||
width="250"
|
||||
class="img-thumbnail">
|
||||
|
||||
<div class="mt-3">
|
||||
|
||||
<label class="d-block">Foto Saat Ini :</label>
|
||||
|
||||
<img
|
||||
src="{{ asset('storage/'.$kategori->foto_kategori) }}"
|
||||
width="250"
|
||||
class="img-thumbnail">
|
||||
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Simpan
|
||||
</button>
|
||||
|
||||
<a href="{{ route('admin.kategori.index') }}"
|
||||
class="btn btn-light">
|
||||
Batal
|
||||
</a>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,141 +3,197 @@
|
|||
@section('title', 'Data Kategori TPS')
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
.deskripsi-truncate-div {
|
||||
max-width: 300px;
|
||||
/* lebar kolom deskripsi */
|
||||
white-space: normal !important;
|
||||
/* override Bootstrap */
|
||||
word-wrap: break-word !important;
|
||||
overflow-wrap: break-word !important;
|
||||
}
|
||||
<style>
|
||||
.deskripsi-truncate-div {
|
||||
max-width: 300px;
|
||||
white-space: normal !important;
|
||||
word-wrap: break-word !important;
|
||||
overflow-wrap: break-word !important;
|
||||
}
|
||||
|
||||
.table td {
|
||||
vertical-align: top;
|
||||
/* supaya teks membungkus ke bawah */
|
||||
}
|
||||
</style>
|
||||
.table td {
|
||||
vertical-align: top;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="mb-3 d-flex justify-content-between">
|
||||
<div>
|
||||
<h4 class="mb-0 card-title">Data Kategori TPS</h4>
|
||||
<p class="mb-0 card-description">
|
||||
Daftar Kategori Tempat Pembuangan Sampah (TPS)
|
||||
</p>
|
||||
</div>
|
||||
<div class="mb-3 d-flex align-items-center">
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
|
||||
<!-- SEARCH -->
|
||||
<form action="{{ route('admin.informasi.index') }}" method="GET"
|
||||
style="width:300px; margin-right:20px;">
|
||||
<input type="text" name="search" value="{{ request('search') }}"
|
||||
class="form-control" placeholder="Cari kategori TPS...">
|
||||
</form>
|
||||
<div class="card-body">
|
||||
|
||||
<!-- BUTTON TAMBAH -->
|
||||
<a href="{{ route('admin.kategori.create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg"></i> Tambah
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<div class="mb-3 d-flex justify-content-between">
|
||||
<div>
|
||||
<h4 class="mb-0 card-title">Data Kategori TPS</h4>
|
||||
<p class="mb-0 card-description">
|
||||
Daftar Kategori Tempat Pembuangan Sampah (TPS)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nama Kategori</th>
|
||||
<th>Foto</th>
|
||||
<th>Deskripsi</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($kategori as $item)
|
||||
<tr>
|
||||
<td>{{ $item->nama_kategori }}</td>
|
||||
<td>
|
||||
@if ($item->foto_kategori)
|
||||
<img src="{{ asset('assets/admin/images/kategori-tps/' . $item->foto_kategori) }}"
|
||||
alt="Foto Kategori"
|
||||
style="width:200px; height:auto; border-radius:2px;">
|
||||
@else
|
||||
<span class="text-muted">-</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<div class="text-justify deskripsi-truncate-div">
|
||||
{{ $item->deskripsi ?? '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ route('admin.kategori.edit', $item->id_kategori_tps) }}"
|
||||
class="btn btn-warning btn-sm me-1" title="Edit">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
<form action="{{ route('admin.kategori.destroy', $item->id_kategori_tps) }}"
|
||||
method="POST" class="form-hapus" style="display:inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger btn-sm">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="mb-3 d-flex align-items-center">
|
||||
|
||||
<!-- SEARCH -->
|
||||
<form action="{{ route('admin.kategori.index') }}" method="GET"
|
||||
style="width:300px; margin-right:20px;">
|
||||
<input type="text"
|
||||
name="search"
|
||||
value="{{ request('search') }}"
|
||||
class="form-control"
|
||||
placeholder="Cari kategori TPS...">
|
||||
</form>
|
||||
|
||||
<!-- BUTTON TAMBAH -->
|
||||
<a href="{{ route('admin.kategori.create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg"></i> Tambah
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
<table class="table">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nama Kategori</th>
|
||||
<th>Foto</th>
|
||||
<th>Deskripsi</th>
|
||||
<th class="text-center">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
@forelse ($kategori as $item)
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
{{ $item->nama_kategori }}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if ($item->foto_kategori)
|
||||
|
||||
<img
|
||||
src="{{ asset('storage/'.$item->foto_kategori) }}"
|
||||
alt="Foto Kategori"
|
||||
style="width:200px; height:auto; border-radius:4px;">
|
||||
|
||||
@else
|
||||
<span class="text-muted">Tidak ada foto</span>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="text-justify deskripsi-truncate-div">
|
||||
{{ $item->deskripsi ?? '-' }}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
|
||||
<!-- EDIT -->
|
||||
<a href="{{ route('admin.kategori.edit',$item->id_kategori_tps) }}"
|
||||
class="btn btn-warning btn-sm me-1">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
|
||||
<!-- DELETE -->
|
||||
<form action="{{ route('admin.kategori.destroy',$item->id_kategori_tps) }}"
|
||||
method="POST"
|
||||
class="form-hapus"
|
||||
style="display:inline;">
|
||||
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
|
||||
<button type="submit" class="btn btn-danger btn-sm">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
@empty
|
||||
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">
|
||||
Data kategori belum tersedia
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endforelse
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- PAGINATION -->
|
||||
<div class="mt-3">
|
||||
{{ $kategori->links() }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.querySelectorAll('.form-hapus').forEach(form => {
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
Swal.fire({
|
||||
title: 'Hapus Data Kategori TPS?',
|
||||
text: 'Data yang sudah dihapus tidak dapat dikembalikan!',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#6c757d',
|
||||
confirmButtonText: 'Ya, Hapus',
|
||||
cancelButtonText: 'Batal',
|
||||
didOpen: () => {
|
||||
document.querySelector('.swal2-popup').style.fontFamily =
|
||||
'Nunito, sans-serif';
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
<script>
|
||||
|
||||
document.querySelectorAll('.form-hapus').forEach(form => {
|
||||
|
||||
form.addEventListener('submit', function(e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
Swal.fire({
|
||||
title: 'Hapus Data Kategori TPS?',
|
||||
text: 'Data yang sudah dihapus tidak dapat dikembalikan!',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#6c757d',
|
||||
confirmButtonText: 'Ya, Hapus',
|
||||
cancelButtonText: 'Batal'
|
||||
}).then((result) => {
|
||||
|
||||
if (result.isConfirmed) {
|
||||
form.submit();
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@if (session('success'))
|
||||
<script>
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: '{{ session('success') }}',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@if (session('success'))
|
||||
|
||||
<script>
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: '{{ session('success') }}',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@endif
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -22,171 +22,166 @@ function decimalToDms($decimal, $type = 'lat')
|
|||
@section('title', 'Edit Data TPS')
|
||||
|
||||
@section('content')
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<h4 class="card-title">Edit Data TPS</h4>
|
||||
<p class="card-description">Form edit data Tempat Pembuangan Sampah</p>
|
||||
<h4 class="card-title">Edit Data TPS</h4>
|
||||
<p class="card-description">Form edit data Tempat Pembuangan Sampah</p>
|
||||
|
||||
<form action="{{ route('admin.tps.update', $tps->id_tps) }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data"
|
||||
class="forms-sample">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<form action="{{ route('admin.tps.update', $tps->id_tps) }}" method="POST"
|
||||
enctype="multipart/form-data" class="forms-sample">
|
||||
|
||||
{{-- NAMA TPS --}}
|
||||
<div class="form-group">
|
||||
<label>Nama TPS</label>
|
||||
<input type="text"
|
||||
name="nama_tps"
|
||||
class="form-control @error('nama_tps') is-invalid @enderror"
|
||||
value="{{ old('nama_tps', $tps->nama_tps) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
@error('nama_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Nama TPS</label>
|
||||
<input type="text" name="nama_tps"
|
||||
class="form-control @error('nama_tps') is-invalid @enderror"
|
||||
value="{{ old('nama_tps', $tps->nama_tps) }}">
|
||||
|
||||
{{-- ALAMAT --}}
|
||||
<div class="form-group">
|
||||
<label>Alamat</label>
|
||||
<input type="text"
|
||||
name="alamat_tps"
|
||||
class="form-control @error('alamat_tps') is-invalid @enderror"
|
||||
value="{{ old('alamat_tps', $tps->alamat_tps) }}">
|
||||
|
||||
@error('alamat_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- KATEGORI --}}
|
||||
<div class="form-group">
|
||||
<label>Kategori TPS</label>
|
||||
<select name="kategori_tps_id"
|
||||
class="form-control @error('kategori_tps_id') is-invalid @enderror">
|
||||
<option value="">-- Pilih Kategori --</option>
|
||||
@foreach ($kategori as $item)
|
||||
<option value="{{ $item->id_kategori_tps }}"
|
||||
{{ old('kategori_tps_id', $tps->kategori_tps_id) == $item->id_kategori_tps ? 'selected' : '' }}>
|
||||
{{ $item->nama_kategori }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
@error('kategori_tps_id')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- TAHUN --}}
|
||||
<div class="form-group">
|
||||
<label>Tahun Pembuatan</label>
|
||||
<input type="number"
|
||||
name="tahun_pembuatan"
|
||||
class="form-control @error('tahun_pembuatan') is-invalid @enderror"
|
||||
value="{{ old('tahun_pembuatan', $tps->tahun_pembuatan) }}">
|
||||
|
||||
@error('tahun_pembuatan')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- KAPASITAS --}}
|
||||
<div class="form-group">
|
||||
<label>Kapasitas TPS</label>
|
||||
<input type="number"
|
||||
name="kapasitas_tps"
|
||||
class="form-control @error('kapasitas_tps') is-invalid @enderror"
|
||||
value="{{ old('kapasitas_tps', $tps->kapasitas_tps) }}">
|
||||
|
||||
@error('kapasitas_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- STATUS --}}
|
||||
<div class="form-group">
|
||||
<label>Status TPS</label>
|
||||
<select name="status_tps"
|
||||
class="form-control @error('status_tps') is-invalid @enderror">
|
||||
<option value="Aktif" {{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>Aktif</option>
|
||||
<option value="Tidak Aktif" {{ old('status_tps', $tps->status_tps) == 'Tidak Aktif' ? 'selected' : '' }}>Tidak Aktif</option>
|
||||
<option value="Pembangunan" {{ old('status_tps', $tps->status_tps) == 'Pembangunan' ? 'selected' : '' }}>Pembangunan</option>
|
||||
</select>
|
||||
|
||||
@error('status_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- LATITUDE --}}
|
||||
<div class="form-group">
|
||||
<label>Latitude</label>
|
||||
<input type="text"
|
||||
name="latitude"
|
||||
class="form-control @error('latitude') is-invalid @enderror"
|
||||
value="{{ old('latitude', decimalToDms($tps->latitude, 'lat')) }}"
|
||||
placeholder="Contoh: 7°35'17.25S">
|
||||
|
||||
@error('latitude')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- LONGITUDE --}}
|
||||
<div class="form-group">
|
||||
<label>Longitude</label>
|
||||
<input type="text"
|
||||
name="longitude"
|
||||
class="form-control @error('longitude') is-invalid @enderror"
|
||||
value="{{ old('longitude', decimalToDms($tps->longitude, 'lng')) }}"
|
||||
placeholder="Contoh: 111°55'0.97E">
|
||||
|
||||
@error('longitude')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- FOTO --}}
|
||||
<div class="form-group">
|
||||
<label>Foto TPS</label>
|
||||
|
||||
<input type="file"
|
||||
name="foto_tps"
|
||||
class="file-upload-default @error('foto_tps') is-invalid @enderror">
|
||||
|
||||
<div class="input-group col-xs-12">
|
||||
<input type="text" class="form-control file-upload-info" disabled placeholder="Upload Foto TPS">
|
||||
<span class="input-group-append">
|
||||
<button class="file-upload-browse btn btn-primary" type="button">Upload</button>
|
||||
</span>
|
||||
@error('nama_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
@error('foto_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
<div class="form-group">
|
||||
<label>Alamat</label>
|
||||
<input type="text" name="alamat_tps"
|
||||
class="form-control @error('alamat_tps') is-invalid @enderror"
|
||||
value="{{ old('alamat_tps', $tps->alamat_tps) }}">
|
||||
|
||||
@if ($tps->foto_tps)
|
||||
<div class="mt-2">
|
||||
<img src="{{ asset('assets/admin/images/tps/' . $tps->foto_tps) }}"
|
||||
width="250"
|
||||
class="img-thumbnail">
|
||||
@error('alamat_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Kategori TPS</label>
|
||||
<select name="kategori_tps_id"
|
||||
class="form-control @error('kategori_tps_id') is-invalid @enderror">
|
||||
|
||||
<option value="">-- Pilih Kategori --</option>
|
||||
|
||||
@foreach ($kategori as $item)
|
||||
<option value="{{ $item->id_kategori_tps }}"
|
||||
{{ old('kategori_tps_id', $tps->kategori_tps_id) == $item->id_kategori_tps ? 'selected' : '' }}>
|
||||
{{ $item->nama_kategori }}
|
||||
</option>
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
|
||||
@error('kategori_tps_id')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Tahun Pembuatan</label>
|
||||
<input type="number" name="tahun_pembuatan"
|
||||
class="form-control @error('tahun_pembuatan') is-invalid @enderror"
|
||||
value="{{ old('tahun_pembuatan', $tps->tahun_pembuatan) }}">
|
||||
|
||||
@error('tahun_pembuatan')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Kapasitas TPS</label>
|
||||
<input type="number" name="kapasitas_tps"
|
||||
class="form-control @error('kapasitas_tps') is-invalid @enderror"
|
||||
value="{{ old('kapasitas_tps', $tps->kapasitas_tps) }}">
|
||||
|
||||
@error('kapasitas_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Status TPS</label>
|
||||
<select name="status_tps" class="form-control @error('status_tps') is-invalid @enderror">
|
||||
|
||||
<option value="Aktif"
|
||||
{{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>Aktif
|
||||
</option>
|
||||
<option value="Tidak Aktif"
|
||||
{{ old('status_tps', $tps->status_tps) == 'Tidak Aktif' ? 'selected' : '' }}>Tidak
|
||||
Aktif</option>
|
||||
<option value="Pembangunan"
|
||||
{{ old('status_tps', $tps->status_tps) == 'Pembangunan' ? 'selected' : '' }}>
|
||||
Pembangunan</option>
|
||||
|
||||
</select>
|
||||
|
||||
@error('status_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Latitude</label>
|
||||
<input type="text" name="latitude"
|
||||
class="form-control @error('latitude') is-invalid @enderror"
|
||||
value="{{ old('latitude', decimalToDms($tps->latitude, 'lat')) }}"
|
||||
placeholder="Contoh: 7°35'17.25S">
|
||||
|
||||
@error('latitude')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Longitude</label>
|
||||
<input type="text" name="longitude"
|
||||
class="form-control @error('longitude') is-invalid @enderror"
|
||||
value="{{ old('longitude', decimalToDms($tps->longitude, 'lng')) }}"
|
||||
placeholder="Contoh: 111°55'0.97E">
|
||||
|
||||
@error('longitude')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Foto TPS</label>
|
||||
|
||||
<input type="file" name="foto_tps"
|
||||
class="file-upload-default @error('foto_tps') is-invalid @enderror">
|
||||
|
||||
<div class="input-group col-xs-12">
|
||||
<input type="text" class="form-control file-upload-info" disabled
|
||||
placeholder="Upload Foto TPS">
|
||||
<span class="input-group-append">
|
||||
<button class="file-upload-browse btn btn-primary" type="button">Upload</button>
|
||||
</span>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('admin.tps.index') }}" class="btn btn-light">Batal</a>
|
||||
</form>
|
||||
@error('foto_tps')
|
||||
<small class="text-danger">{{ $message }}</small>
|
||||
@enderror
|
||||
|
||||
@if ($tps->foto_tps)
|
||||
<div class="mt-2">
|
||||
<img src="{{ asset('storage/' . $tps->foto_tps) }}" width="250"
|
||||
class="img-thumbnail">
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('admin.tps.index') }}" class="btn btn-light">Batal</a>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
@section('title', 'Data TPS')
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
```
|
||||
<div class="mb-3 d-flex justify-content-between align-items-center">
|
||||
|
||||
<div>
|
||||
|
|
@ -60,8 +62,8 @@ class="form-control" placeholder="Cari nama TPS...">
|
|||
|
||||
<td>
|
||||
@if ($item->foto_tps)
|
||||
<img src="{{ asset('assets/admin/images/tps/' . $item->foto_tps) }}"
|
||||
alt="Foto TPS" style="width:200px;height:auto;border-radius:4px;">
|
||||
<img src="{{ asset('storage/' . $item->foto_tps) }}" alt="Foto TPS"
|
||||
style="width:200px;height:auto;border-radius:4px;">
|
||||
@else
|
||||
<span class="text-muted">-</span>
|
||||
@endif
|
||||
|
|
@ -121,8 +123,9 @@ class="btn btn-warning btn-sm me-1">
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.querySelectorAll('.form-hapus').forEach(form => {
|
||||
|
|
@ -156,7 +159,6 @@ class="btn btn-warning btn-sm me-1">
|
|||
});
|
||||
</script>
|
||||
|
||||
|
||||
@if (session('success'))
|
||||
<script>
|
||||
Swal.fire({
|
||||
|
|
|
|||
Loading…
Reference in New Issue