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