crud kelola tps fiks
This commit is contained in:
parent
1f0d13c9ba
commit
343f200e1e
|
|
@ -9,20 +9,19 @@
|
|||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
public function up()
|
||||
{
|
||||
Schema::table('lokasi_tps', function (Blueprint $table) {
|
||||
//
|
||||
$table->text('alamat_tps')->nullable()->after('nama_tps');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
public function down()
|
||||
{
|
||||
Schema::table('lokasi_tps', function (Blueprint $table) {
|
||||
//
|
||||
if (Schema::hasColumn('lokasi_tps', 'alamat_tps')) {
|
||||
$table->dropColumn('alamat_tps');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,15 @@
|
|||
<!-- endinject -->
|
||||
<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 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>
|
||||
|
||||
|
|
@ -28,10 +37,10 @@
|
|||
<div class="container-scroller">
|
||||
<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">
|
||||
<a class="navbar-brand brand-logo mr-5" href="index.html"><img 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') }}"
|
||||
alt="logo" /></a>
|
||||
<a class="navbar-brand brand-logo mr-5" href="index.html"><img
|
||||
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') }}" alt="logo" /></a>
|
||||
</div>
|
||||
<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">
|
||||
|
|
@ -239,6 +248,7 @@
|
|||
<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/js/file-upload.js') }}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<!-- End custom js for this page-->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -15,14 +15,13 @@
|
|||
<!-- NAMA TPS -->
|
||||
<div class="form-group">
|
||||
<label>Nama TPS</label>
|
||||
<input type="text" name="nama_tps" class="form-control"
|
||||
placeholder="Nama TPS" required>
|
||||
<input type="text" name="nama_tps" class="form-control" placeholder="Nama TPS" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Alamat</label>
|
||||
<input type="text" name="alamat" class="form-control"
|
||||
placeholder="Alamat TPS" required>
|
||||
<input type="text" name="alamat_tps" class="form-control" placeholder="Alamat TPS"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<!-- KATEGORI TPS -->
|
||||
|
|
@ -48,8 +47,8 @@
|
|||
<!-- KAPASITAS -->
|
||||
<div class="form-group">
|
||||
<label>Kapasitas</label>
|
||||
<input type="text" name="kapasitas_tps" class="form-control"
|
||||
placeholder="Kapasitas TPS" required>
|
||||
<input type="text" name="kapasitas_tps" class="form-control" placeholder="Kapasitas TPS"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<!-- STATUS -->
|
||||
|
|
@ -65,22 +64,31 @@
|
|||
<!-- LATITUDE -->
|
||||
<div class="form-group">
|
||||
<label>Latitude</label>
|
||||
<input type="text" name="latitude" class="form-control"
|
||||
placeholder="Latitude" required>
|
||||
<input type="text" name="latitude" class="form-control" placeholder="Latitude" required>
|
||||
</div>
|
||||
|
||||
<!-- LONGITUDE -->
|
||||
<div class="form-group">
|
||||
<label>Longitude</label>
|
||||
<input type="text" name="longitude" class="form-control"
|
||||
placeholder="Longitude" required>
|
||||
<input type="text" name="longitude" class="form-control" placeholder="Longitude"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<!-- FOTO -->
|
||||
<div class="form-group">
|
||||
<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>
|
||||
|
||||
<button type="submit" class="btn btn-primary mr-2">Simpan</button>
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@
|
|||
Form edit data Tempat Pembuangan Sampah
|
||||
</p>
|
||||
|
||||
<form action="{{ route('admin.tps.update', $tps->id) }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data"
|
||||
<form action="{{ route('admin.tps.update', $tps->id) }}" method="POST" enctype="multipart/form-data"
|
||||
class="forms-sample">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
|
@ -21,20 +19,15 @@ class="forms-sample">
|
|||
{{-- Nama TPS --}}
|
||||
<div class="form-group">
|
||||
<label>Nama TPS</label>
|
||||
<input type="text"
|
||||
name="nama_tps"
|
||||
class="form-control"
|
||||
value="{{ old('nama_tps', $tps->nama_tps) }}"
|
||||
required>
|
||||
<input type="text" name="nama_tps" class="form-control"
|
||||
value="{{ old('nama_tps', $tps->nama_tps) }}" required>
|
||||
</div>
|
||||
|
||||
{{-- Alamat --}}
|
||||
<div class="form-group">
|
||||
<label>Alamat</label>
|
||||
<input type="text"
|
||||
name="alamat"
|
||||
class="form-control"
|
||||
value="{{ old('alamat', $tps->alamat) }}">
|
||||
<input type="text" name="alamat_tps" class="form-control"
|
||||
value="{{ old('alamat_tps', $tps->alamat_tps) }}">
|
||||
</div>
|
||||
|
||||
{{-- Kategori TPS --}}
|
||||
|
|
@ -51,11 +44,24 @@ class="form-control"
|
|||
</select>
|
||||
</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 --}}
|
||||
<div class="form-group">
|
||||
<label>Status TPS</label>
|
||||
<select name="status_tps" class="form-control" required>
|
||||
<option value="">-- Pilih Status --</option>
|
||||
<option value="Aktif"
|
||||
{{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>
|
||||
Aktif
|
||||
|
|
@ -64,24 +70,25 @@ class="form-control"
|
|||
{{ 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>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- Latitude --}}
|
||||
<div class="form-group">
|
||||
<label>Latitude</label>
|
||||
<input type="text"
|
||||
name="latitude"
|
||||
class="form-control"
|
||||
<input type="text" name="latitude" class="form-control"
|
||||
value="{{ old('latitude', $tps->latitude) }}">
|
||||
</div>
|
||||
|
||||
{{-- Longitude --}}
|
||||
<div class="form-group">
|
||||
<label>Longitude</label>
|
||||
<input type="text"
|
||||
name="longitude"
|
||||
class="form-control"
|
||||
<input type="text" name="longitude" class="form-control"
|
||||
value="{{ old('longitude', $tps->longitude) }}">
|
||||
</div>
|
||||
|
||||
|
|
@ -89,18 +96,13 @@ class="form-control"
|
|||
<div class="form-group">
|
||||
<label>Foto TPS</label>
|
||||
|
||||
<input type="file"
|
||||
name="foto_tps"
|
||||
class="file-upload-default">
|
||||
<input type="file" name="foto_tps" class="file-upload-default">
|
||||
|
||||
<div class="input-group col-xs-12">
|
||||
<input type="text"
|
||||
class="form-control file-upload-info"
|
||||
disabled
|
||||
<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">
|
||||
<button class="file-upload-browse btn btn-primary" type="button">
|
||||
Upload
|
||||
</button>
|
||||
</span>
|
||||
|
|
@ -109,8 +111,7 @@ class="form-control file-upload-info"
|
|||
{{-- Foto Lama --}}
|
||||
@if ($tps->foto_tps)
|
||||
<div class="mt-2">
|
||||
<img src="{{ asset('storage/'.$tps->foto_tps) }}"
|
||||
width="120"
|
||||
<img src="{{ asset('storage/' . $tps->foto_tps) }}" width="250"
|
||||
class="img-thumbnail">
|
||||
</div>
|
||||
@endif
|
||||
|
|
@ -118,10 +119,9 @@ class="img-thumbnail">
|
|||
|
||||
{{-- Button --}}
|
||||
<button type="submit" class="btn btn-primary mr-2">
|
||||
Simpan Perubahan
|
||||
Simpan
|
||||
</button>
|
||||
<a href="{{ route('admin.tps.index') }}"
|
||||
class="btn btn-light">
|
||||
<a href="{{ route('admin.tps.index') }}" class="btn btn-light">
|
||||
Batal
|
||||
</a>
|
||||
|
||||
|
|
|
|||
|
|
@ -45,21 +45,24 @@
|
|||
<!-- FOTO -->
|
||||
<td>
|
||||
@if ($item->foto_tps)
|
||||
<img src="{{ asset('storage/' . $item->foto_tps) }}"
|
||||
alt="Foto TPS"
|
||||
height="60"
|
||||
style="border-radius:6px">
|
||||
<img src="{{ asset('storage/' . $item->foto_tps) }}" alt="Foto TPS"
|
||||
style="
|
||||
width:200px;
|
||||
height:auto;
|
||||
border-radius:2px;
|
||||
">
|
||||
@else
|
||||
<span class="text-muted">-</span>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
|
||||
<!-- STATUS -->
|
||||
<td>
|
||||
@if ($item->status_tps == 'Aktif')
|
||||
<label class="badge badge-success">Aktif</label>
|
||||
@elseif ($item->status_tps == 'Non-Aktif')
|
||||
<label class="badge badge-secondary">Non-Aktif</label>
|
||||
@elseif ($item->status_tps == 'Tidak Aktif')
|
||||
<label class="badge badge-secondary">Tidak Aktif</label>
|
||||
@else
|
||||
<label class="badge badge-warning">Pembangunan</label>
|
||||
@endif
|
||||
|
|
@ -72,16 +75,15 @@ class="btn btn-warning btn-sm me-1">
|
|||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
|
||||
<form action="{{ route('admin.tps.destroy', $item->id) }}"
|
||||
method="POST"
|
||||
style="display:inline;">
|
||||
<form action="{{ route('admin.tps.destroy', $item->id) }}" method="POST"
|
||||
class="form-hapus" style="display:inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger btn-sm"
|
||||
onclick="return confirm('Yakin ingin menghapus data ini?')">
|
||||
<button type="submit" class="btn btn-danger btn-sm">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
|
|
@ -101,4 +103,44 @@ class="btn btn-warning btn-sm me-1">
|
|||
</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
|
||||
|
|
|
|||
Loading…
Reference in New Issue