crud kelola tps fiks

This commit is contained in:
rahmagustin 2026-01-12 20:59:12 +07:00
parent 1f0d13c9ba
commit 343f200e1e
5 changed files with 354 additions and 295 deletions

View File

@ -9,20 +9,19 @@
/** /**
* Run the migrations. * Run the migrations.
*/ */
public function up(): void public function up()
{ {
Schema::table('lokasi_tps', function (Blueprint $table) { Schema::table('lokasi_tps', function (Blueprint $table) {
// $table->text('alamat_tps')->nullable()->after('nama_tps');
}); });
} }
/** public function down()
* Reverse the migrations.
*/
public function down(): void
{ {
Schema::table('lokasi_tps', function (Blueprint $table) { Schema::table('lokasi_tps', function (Blueprint $table) {
// if (Schema::hasColumn('lokasi_tps', 'alamat_tps')) {
$table->dropColumn('alamat_tps');
}
}); });
} }
}; };

View File

@ -21,6 +21,15 @@
<!-- endinject --> <!-- endinject -->
<link rel="shortcut icon" href="{{ asset('assets/admin/images/favicon.png') }}" /> <link rel="shortcut icon" href="{{ asset('assets/admin/images/favicon.png') }}" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
<style>
/* Turunkan icon SweetAlert2 */
.swal2-icon {
margin-top: 30px !important;
margin-bottom: 10px !important;
}
</style>
</head> </head>
@ -28,10 +37,10 @@
<div class="container-scroller"> <div class="container-scroller">
<nav class="navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row"> <nav class="navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
<div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center"> <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">
<a class="navbar-brand brand-logo mr-5" href="index.html"><img src="{{ asset('assets/admin/images/logo.svg') }}" class="mr-2" <a class="navbar-brand brand-logo mr-5" href="index.html"><img
alt="logo" /></a> src="{{ asset('assets/admin/images/logo.svg') }}" class="mr-2" alt="logo" /></a>
<a class="navbar-brand brand-logo-mini" href="index.html"><img src="{{ asset('assets/admin/images/logo-mini.svg') }}" <a class="navbar-brand brand-logo-mini" href="index.html"><img
alt="logo" /></a> src="{{ asset('assets/admin/images/logo-mini.svg') }}" alt="logo" /></a>
</div> </div>
<div class="navbar-menu-wrapper d-flex align-items-center justify-content-end"> <div class="navbar-menu-wrapper d-flex align-items-center justify-content-end">
<button class="navbar-toggler navbar-toggler align-self-center" type="button" data-toggle="minimize"> <button class="navbar-toggler navbar-toggler align-self-center" type="button" data-toggle="minimize">
@ -239,6 +248,7 @@
<script src="{{ asset('assets/admin/js/Chart.roundedBarCharts.js') }}"></script> <script src="{{ asset('assets/admin/js/Chart.roundedBarCharts.js') }}"></script>
<script src="{{ asset('assets/admin/vendors/js/vendor.bundle.base.js') }}"></script> <script src="{{ asset('assets/admin/vendors/js/vendor.bundle.base.js') }}"></script>
<script src="{{ asset('assets/admin/js/file-upload.js') }}"></script> <script src="{{ asset('assets/admin/js/file-upload.js') }}"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- End custom js for this page--> <!-- End custom js for this page-->
</body> </body>

View File

@ -1,7 +1,7 @@
@extends('admin.template') @extends('admin.template')
@section('content') @section('content')
<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">
@ -15,14 +15,13 @@
<!-- NAMA TPS --> <!-- NAMA TPS -->
<div class="form-group"> <div class="form-group">
<label>Nama TPS</label> <label>Nama TPS</label>
<input type="text" name="nama_tps" class="form-control" <input type="text" name="nama_tps" class="form-control" placeholder="Nama TPS" required>
placeholder="Nama TPS" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Alamat</label> <label>Alamat</label>
<input type="text" name="alamat" class="form-control" <input type="text" name="alamat_tps" class="form-control" placeholder="Alamat TPS"
placeholder="Alamat TPS" required> required>
</div> </div>
<!-- KATEGORI TPS --> <!-- KATEGORI TPS -->
@ -48,8 +47,8 @@
<!-- KAPASITAS --> <!-- KAPASITAS -->
<div class="form-group"> <div class="form-group">
<label>Kapasitas</label> <label>Kapasitas</label>
<input type="text" name="kapasitas_tps" class="form-control" <input type="text" name="kapasitas_tps" class="form-control" placeholder="Kapasitas TPS"
placeholder="Kapasitas TPS" required> required>
</div> </div>
<!-- STATUS --> <!-- STATUS -->
@ -65,22 +64,31 @@
<!-- LATITUDE --> <!-- LATITUDE -->
<div class="form-group"> <div class="form-group">
<label>Latitude</label> <label>Latitude</label>
<input type="text" name="latitude" class="form-control" <input type="text" name="latitude" class="form-control" placeholder="Latitude" required>
placeholder="Latitude" required>
</div> </div>
<!-- LONGITUDE --> <!-- LONGITUDE -->
<div class="form-group"> <div class="form-group">
<label>Longitude</label> <label>Longitude</label>
<input type="text" name="longitude" class="form-control" <input type="text" name="longitude" class="form-control" placeholder="Longitude"
placeholder="Longitude" required> required>
</div> </div>
<!-- FOTO --> <!-- FOTO -->
<div class="form-group"> <div class="form-group">
<label>Foto TPS</label> <label>Foto TPS</label>
<input type="file" name="foto_tps"
class="form-control" accept="image/*"> <input type="file" name="foto_tps" id="foto_tps" class="file-upload-default">
<div class="input-group col-xs-12">
<input type="text" 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">
Upload
</button>
</span>
</div>
</div> </div>
<button type="submit" class="btn btn-primary mr-2">Simpan</button> <button type="submit" class="btn btn-primary mr-2">Simpan</button>
@ -91,5 +99,5 @@ class="form-control" accept="image/*">
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@endsection @endsection

View File

@ -1,7 +1,7 @@
@extends('admin.template') @extends('admin.template')
@section('content') @section('content')
<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">
@ -11,9 +11,7 @@
Form edit data Tempat Pembuangan Sampah Form edit data Tempat Pembuangan Sampah
</p> </p>
<form action="{{ route('admin.tps.update', $tps->id) }}" <form action="{{ route('admin.tps.update', $tps->id) }}" method="POST" enctype="multipart/form-data"
method="POST"
enctype="multipart/form-data"
class="forms-sample"> class="forms-sample">
@csrf @csrf
@method('PUT') @method('PUT')
@ -21,20 +19,15 @@ class="forms-sample">
{{-- Nama TPS --}} {{-- 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" class="form-control"
name="nama_tps" value="{{ old('nama_tps', $tps->nama_tps) }}" required>
class="form-control"
value="{{ old('nama_tps', $tps->nama_tps) }}"
required>
</div> </div>
{{-- Alamat --}} {{-- Alamat --}}
<div class="form-group"> <div class="form-group">
<label>Alamat</label> <label>Alamat</label>
<input type="text" <input type="text" name="alamat_tps" class="form-control"
name="alamat" value="{{ old('alamat_tps', $tps->alamat_tps) }}">
class="form-control"
value="{{ old('alamat', $tps->alamat) }}">
</div> </div>
{{-- Kategori TPS --}} {{-- Kategori TPS --}}
@ -42,7 +35,7 @@ class="form-control"
<label>Kategori TPS</label> <label>Kategori TPS</label>
<select name="kategori_tps_id" class="form-control" required> <select name="kategori_tps_id" class="form-control" required>
<option value="">-- Pilih Kategori --</option> <option value="">-- Pilih Kategori --</option>
@foreach($kategori as $item) @foreach ($kategori as $item)
<option value="{{ $item->id }}" <option value="{{ $item->id }}"
{{ $tps->kategori_tps_id == $item->id ? 'selected' : '' }}> {{ $tps->kategori_tps_id == $item->id ? 'selected' : '' }}>
{{ $item->nama_kategori }} {{ $item->nama_kategori }}
@ -51,11 +44,24 @@ class="form-control"
</select> </select>
</div> </div>
{{-- Tahun Pembuatan --}}
<div class="form-group">
<label>Tahun Pembuatan</label>
<input type="number" name="tahun_pembuatan" class="form-control"
value="{{ old('tahun_pembuatan', $tps->tahun_pembuatan) }}" required>
</div>
{{-- Kapasitas TPS --}}
<div class="form-group">
<label>Kapasitas TPS</label>
<input type="text" name="kapasitas_tps" class="form-control"
value="{{ old('kapasitas_tps', $tps->kapasitas_tps) }}" required>
</div>
{{-- Status TPS --}} {{-- Status TPS --}}
<div class="form-group"> <div class="form-group">
<label>Status TPS</label> <label>Status TPS</label>
<select name="status_tps" class="form-control" required> <select name="status_tps" class="form-control" required>
<option value="">-- Pilih Status --</option>
<option value="Aktif" <option value="Aktif"
{{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}> {{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>
Aktif Aktif
@ -64,24 +70,25 @@ class="form-control"
{{ old('status_tps', $tps->status_tps) == 'Tidak Aktif' ? 'selected' : '' }}> {{ old('status_tps', $tps->status_tps) == 'Tidak Aktif' ? 'selected' : '' }}>
Tidak Aktif Tidak Aktif
</option> </option>
<option value="Pembangunan"
{{ old('status_tps', $tps->status_tps) == 'Pembangunan' ? 'selected' : '' }}>
Pembangunan
</option>
</select> </select>
</div> </div>
{{-- Latitude --}} {{-- Latitude --}}
<div class="form-group"> <div class="form-group">
<label>Latitude</label> <label>Latitude</label>
<input type="text" <input type="text" name="latitude" class="form-control"
name="latitude"
class="form-control"
value="{{ old('latitude', $tps->latitude) }}"> value="{{ old('latitude', $tps->latitude) }}">
</div> </div>
{{-- Longitude --}} {{-- Longitude --}}
<div class="form-group"> <div class="form-group">
<label>Longitude</label> <label>Longitude</label>
<input type="text" <input type="text" name="longitude" class="form-control"
name="longitude"
class="form-control"
value="{{ old('longitude', $tps->longitude) }}"> value="{{ old('longitude', $tps->longitude) }}">
</div> </div>
@ -89,28 +96,22 @@ class="form-control"
<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" class="file-upload-default">
name="foto_tps"
class="file-upload-default">
<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" disabled
class="form-control file-upload-info"
disabled
placeholder="Upload Foto TPS"> placeholder="Upload Foto TPS">
<span class="input-group-append"> <span class="input-group-append">
<button class="file-upload-browse btn btn-primary" <button class="file-upload-browse btn btn-primary" type="button">
type="button">
Upload Upload
</button> </button>
</span> </span>
</div> </div>
{{-- Foto Lama --}} {{-- Foto Lama --}}
@if($tps->foto_tps) @if ($tps->foto_tps)
<div class="mt-2"> <div class="mt-2">
<img src="{{ asset('storage/'.$tps->foto_tps) }}" <img src="{{ asset('storage/' . $tps->foto_tps) }}" width="250"
width="120"
class="img-thumbnail"> class="img-thumbnail">
</div> </div>
@endif @endif
@ -118,10 +119,9 @@ class="img-thumbnail">
{{-- Button --}} {{-- Button --}}
<button type="submit" class="btn btn-primary mr-2"> <button type="submit" class="btn btn-primary mr-2">
Simpan Perubahan Simpan
</button> </button>
<a href="{{ route('admin.tps.index') }}" <a href="{{ route('admin.tps.index') }}" class="btn btn-light">
class="btn btn-light">
Batal Batal
</a> </a>
@ -130,5 +130,5 @@ class="btn btn-light">
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@endsection @endsection

View File

@ -1,7 +1,7 @@
@extends('admin.template') @extends('admin.template')
@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">
@ -45,21 +45,24 @@
<!-- FOTO --> <!-- FOTO -->
<td> <td>
@if ($item->foto_tps) @if ($item->foto_tps)
<img src="{{ asset('storage/' . $item->foto_tps) }}" <img src="{{ asset('storage/' . $item->foto_tps) }}" alt="Foto TPS"
alt="Foto TPS" style="
height="60" width:200px;
style="border-radius:6px"> height:auto;
border-radius:2px;
">
@else @else
<span class="text-muted">-</span> <span class="text-muted">-</span>
@endif @endif
</td> </td>
<!-- STATUS --> <!-- STATUS -->
<td> <td>
@if ($item->status_tps == 'Aktif') @if ($item->status_tps == 'Aktif')
<label class="badge badge-success">Aktif</label> <label class="badge badge-success">Aktif</label>
@elseif ($item->status_tps == 'Non-Aktif') @elseif ($item->status_tps == 'Tidak Aktif')
<label class="badge badge-secondary">Non-Aktif</label> <label class="badge badge-secondary">Tidak Aktif</label>
@else @else
<label class="badge badge-warning">Pembangunan</label> <label class="badge badge-warning">Pembangunan</label>
@endif @endif
@ -72,16 +75,15 @@ class="btn btn-warning btn-sm me-1">
<i class="bi bi-pencil-square"></i> <i class="bi bi-pencil-square"></i>
</a> </a>
<form action="{{ route('admin.tps.destroy', $item->id) }}" <form action="{{ route('admin.tps.destroy', $item->id) }}" method="POST"
method="POST" class="form-hapus" style="display:inline;">
style="display:inline;">
@csrf @csrf
@method('DELETE') @method('DELETE')
<button class="btn btn-danger btn-sm" <button type="submit" class="btn btn-danger btn-sm">
onclick="return confirm('Yakin ingin menghapus data ini?')">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
</button> </button>
</form> </form>
</td> </td>
</tr> </tr>
@empty @empty
@ -100,5 +102,45 @@ class="btn btn-warning btn-sm me-1">
</div> </div>
</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 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>
@if (session('success'))
<script>
Swal.fire({
icon: 'success',
title: 'Berhasil',
text: '{{ session('success') }}',
timer: 2000,
showConfirmButton: false
});
</script>
@endif
@endsection @endsection