fungsi crud kategori tps admin
This commit is contained in:
parent
f76c1fc2fa
commit
7be1b5d68e
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\KategoriTps;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class KategoriTpsController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$title = 'Kategori TPS';
|
||||
$kategori = KategoriTps::all();
|
||||
|
||||
return view('admin.kategori-tps.index', compact('title', 'kategori'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$title = 'Tambah Kategori TPS';
|
||||
return view('admin.kategori-tps.create', compact('title'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'nama_kategori' => 'required|string|max:100',
|
||||
'deskripsi' => 'nullable|string',
|
||||
'foto_kategori' => 'nullable|image|mimes:jpg,jpeg,png|max:2048'
|
||||
]);
|
||||
|
||||
if ($request->hasFile('foto_kategori')) {
|
||||
$data['foto_kategori'] = $request->file('foto_kategori')
|
||||
->store('kategori', 'public');
|
||||
}
|
||||
|
||||
KategoriTps::create($data);
|
||||
|
||||
return redirect()
|
||||
->route('admin.kategori.index')
|
||||
->with('success', 'Kategori berhasil ditambahkan');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$title = 'Edit Kategori TPS';
|
||||
$kategori = KategoriTps::findOrFail($id);
|
||||
|
||||
return view('admin.kategori-tps.edit', compact('title', 'kategori'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$kategori = KategoriTps::findOrFail($id);
|
||||
|
||||
$data = $request->validate([
|
||||
'nama_kategori' => 'required|string|max:100',
|
||||
'deskripsi' => 'nullable|string',
|
||||
'foto_kategori' => 'nullable|image|mimes:jpg,jpeg,png|max:2048'
|
||||
]);
|
||||
|
||||
if ($request->hasFile('foto_kategori')) {
|
||||
if ($kategori->foto_kategori) {
|
||||
Storage::disk('public')->delete($kategori->foto_kategori);
|
||||
}
|
||||
|
||||
$data['foto_kategori'] = $request->file('foto_kategori')
|
||||
->store('kategori', 'public');
|
||||
}
|
||||
|
||||
$kategori->update($data);
|
||||
|
||||
return redirect()
|
||||
->route('admin.kategori.index')
|
||||
->with('success', 'Kategori berhasil diperbarui');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$kategori = KategoriTps::findOrFail($id);
|
||||
|
||||
if ($kategori->foto_kategori) {
|
||||
Storage::disk('public')->delete($kategori->foto_kategori);
|
||||
}
|
||||
|
||||
$kategori->delete();
|
||||
|
||||
return redirect()
|
||||
->route('admin.kategori.index')
|
||||
->with('success', 'Kategori berhasil dihapus');
|
||||
}
|
||||
}
|
||||
|
|
@ -4,22 +4,127 @@
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\LokasiTps;
|
||||
use App\Models\KategoriTps;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class TpsController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$title = 'Tps Admin';
|
||||
return view('admin.tps.index', compact('title'));
|
||||
$title = 'Data TPS';
|
||||
|
||||
// Ambil TPS + kategori + jumlah aduan
|
||||
$tps = LokasiTps::with('kategori')
|
||||
->withCount('aduan')
|
||||
->get();
|
||||
|
||||
return view('admin.tps.index', compact('title', 'tps'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$title = 'Tambah Tps Admin';
|
||||
return view('admin.tps.create', compact('title'));
|
||||
$title = 'Tambah TPS';
|
||||
$kategori = KategoriTps::all();
|
||||
|
||||
return view('admin.tps.create', compact('title', 'kategori'));
|
||||
}
|
||||
public function edit()
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$title = 'Edit Tps Admin';
|
||||
return view('admin.tps.edit', compact('title'));
|
||||
$request->validate([
|
||||
'kategori_tps_id' => 'required|exists:kategori_tps,id',
|
||||
'nama_tps' => 'required|string|max:255',
|
||||
'status_tps' => 'required',
|
||||
'tahun_pembuatan' => 'required|numeric',
|
||||
'kapasitas_tps' => 'required',
|
||||
'latitude' => 'required',
|
||||
'longitude' => 'required',
|
||||
'foto_tps' => 'nullable|image|mimes:jpg,jpeg,png|max:2048',
|
||||
]);
|
||||
|
||||
// Upload foto
|
||||
if ($request->hasFile('foto_tps')) {
|
||||
$foto = $request->file('foto_tps')->store('foto-tps', 'public');
|
||||
} else {
|
||||
$foto = null;
|
||||
}
|
||||
|
||||
LokasiTps::create([
|
||||
'kategori_tps_id' => $request->kategori_tps_id,
|
||||
'nama_tps' => $request->nama_tps,
|
||||
'status_tps' => $request->status_tps,
|
||||
'tahun_pembuatan' => $request->tahun_pembuatan,
|
||||
'kapasitas_tps' => $request->kapasitas_tps,
|
||||
'latitude' => $request->latitude,
|
||||
'longitude' => $request->longitude,
|
||||
'foto_tps' => $foto,
|
||||
]);
|
||||
|
||||
return redirect()->route('tps.index')
|
||||
->with('success', 'Data TPS berhasil ditambahkan');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$title = 'Edit TPS';
|
||||
$tps = LokasiTps::findOrFail($id);
|
||||
$kategori = KategoriTps::all();
|
||||
|
||||
return view('admin.tps.edit', compact('title', 'tps', 'kategori'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$tps = LokasiTps::findOrFail($id);
|
||||
|
||||
$request->validate([
|
||||
'kategori_tps_id' => 'required|exists:kategori_tps,id',
|
||||
'nama_tps' => 'required|string|max:255',
|
||||
'status_tps' => 'required',
|
||||
'tahun_pembuatan' => 'required|numeric',
|
||||
'kapasitas_tps' => 'required',
|
||||
'latitude' => 'required',
|
||||
'longitude' => 'required',
|
||||
'foto_tps' => 'nullable|image|mimes:jpg,jpeg,png|max:2048',
|
||||
]);
|
||||
|
||||
// Jika upload foto baru
|
||||
if ($request->hasFile('foto_tps')) {
|
||||
if ($tps->foto_tps) {
|
||||
Storage::disk('public')->delete($tps->foto_tps);
|
||||
}
|
||||
$foto = $request->file('foto_tps')->store('foto-tps', 'public');
|
||||
} else {
|
||||
$foto = $tps->foto_tps;
|
||||
}
|
||||
|
||||
$tps->update([
|
||||
'kategori_tps_id' => $request->kategori_tps_id,
|
||||
'nama_tps' => $request->nama_tps,
|
||||
'status_tps' => $request->status_tps,
|
||||
'tahun_pembuatan' => $request->tahun_pembuatan,
|
||||
'kapasitas_tps' => $request->kapasitas_tps,
|
||||
'latitude' => $request->latitude,
|
||||
'longitude' => $request->longitude,
|
||||
'foto_tps' => $foto,
|
||||
]);
|
||||
|
||||
return redirect()->route('tps.index')
|
||||
->with('success', 'Data TPS berhasil diperbarui');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$tps = LokasiTps::findOrFail($id);
|
||||
|
||||
if ($tps->foto_tps) {
|
||||
Storage::disk('public')->delete($tps->foto_tps);
|
||||
}
|
||||
|
||||
$tps->delete();
|
||||
|
||||
return redirect()->route('tps.index')
|
||||
->with('success', 'Data TPS berhasil dihapus');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,14 @@ class KategoriTps extends Model
|
|||
{
|
||||
protected $table = 'kategori_tps';
|
||||
|
||||
protected $fillable = ['nama_kategori', 'deskripsi'];
|
||||
protected $fillable = [
|
||||
'nama_kategori',
|
||||
'deskripsi',
|
||||
'foto_kategori'
|
||||
];
|
||||
|
||||
public function lokasiTps()
|
||||
{
|
||||
return $this->hasMany(LokasiTps::class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LokasiTps extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'lokasi_tps';
|
||||
|
||||
protected $fillable = [
|
||||
|
|
@ -16,17 +19,24 @@ class LokasiTps extends Model
|
|||
'kapasitas_tps',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'foto_tps'
|
||||
'foto_tps',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relasi ke tabel kategori_tps
|
||||
* One TPS belongs to one kategori
|
||||
*/
|
||||
public function kategori()
|
||||
{
|
||||
return $this->belongsTo(KategoriTps::class, 'kategori_tps_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke tabel aduan_tps
|
||||
* One TPS has many aduan
|
||||
*/
|
||||
public function aduan()
|
||||
{
|
||||
return $this->hasMany(AduanTps::class);
|
||||
return $this->hasMany(AduanTps::class, 'lokasi_tps_id');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('kategori_tps', function (Blueprint $table) {
|
||||
$table->string('foto_kategori')->nullable()->after('deskripsi');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('kategori_tps', function (Blueprint $table) {
|
||||
$table->dropColumn('foto_kategori');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -6,54 +6,43 @@
|
|||
<div class="col-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Basic form elements</h4>
|
||||
<p class="card-description">
|
||||
Basic form elements
|
||||
</p>
|
||||
<form class="forms-sample">
|
||||
<h4 class="card-title">Tambah Kategori TPS</h4>
|
||||
<p class="card-description">Form tambah data kategori TPS</p>
|
||||
|
||||
<form action="{{ route('admin.kategori.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<div class="form-group">
|
||||
<label for="exampleInputName1">Name</label>
|
||||
<input type="text" class="form-control" id="exampleInputName1" placeholder="Name">
|
||||
<label>Nama Kategori</label>
|
||||
<input type="text" name="nama_kategori" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail3">Email address</label>
|
||||
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
|
||||
<label for="exampleTextarea1">Deskripsi</label>
|
||||
<textarea name="deskripsi" class="form-control" id="exampleTextarea1" rows="4"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="exampleInputPassword4">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword4"
|
||||
placeholder="Password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleSelectGender">Gender</label>
|
||||
<select class="form-control" id="exampleSelectGender">
|
||||
<option>Male</option>
|
||||
<option>Female</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>File upload</label>
|
||||
<input type="file" name="img[]" class="file-upload-default">
|
||||
<label>Foto Kategori</label>
|
||||
|
||||
<input type="file" name="foto_kategori" id="foto_kategori" class="file-upload-default">
|
||||
|
||||
<div class="input-group col-xs-12">
|
||||
<input type="text" class="form-control file-upload-info" disabled
|
||||
placeholder="Upload Image">
|
||||
placeholder="Upload Foto">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputCity1">City</label>
|
||||
<input type="text" class="form-control" id="exampleInputCity1"
|
||||
placeholder="Location">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleTextarea1">Textarea</label>
|
||||
<textarea class="form-control" id="exampleTextarea1" rows="4"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mr-2">Submit</button>
|
||||
<button class="btn btn-light">Cancel</button>
|
||||
|
||||
|
||||
<button class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,54 +6,59 @@
|
|||
<div class="col-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Basic form elements</h4>
|
||||
<p class="card-description">
|
||||
Basic form elements
|
||||
</p>
|
||||
<form class="forms-sample">
|
||||
<h4 class="card-title">Edit Kategori TPS</h4>
|
||||
<p class="card-description">Form edit data kategori TPS</p>
|
||||
|
||||
<form action="{{ route('admin.kategori.update', $kategori->id) }}" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div class="form-group">
|
||||
<label for="exampleInputName1">Name</label>
|
||||
<input type="text" class="form-control" id="exampleInputName1" placeholder="Name">
|
||||
<label>Nama Kategori</label>
|
||||
<input type="text" name="nama_kategori" value="{{ $kategori->nama_kategori }}"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail3">Email address</label>
|
||||
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
|
||||
<label>Deskripsi</label>
|
||||
<textarea name="deskripsi" class="form-control">{{ $kategori->deskripsi }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="exampleInputPassword4">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword4"
|
||||
placeholder="Password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleSelectGender">Gender</label>
|
||||
<select class="form-control" id="exampleSelectGender">
|
||||
<option>Male</option>
|
||||
<option>Female</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>File upload</label>
|
||||
<input type="file" name="img[]" class="file-upload-default">
|
||||
<label>Foto Kategori</label>
|
||||
|
||||
<!-- INPUT FILE ASLI (HIDDEN - TEMPLATE) -->
|
||||
<input type="file" name="foto_kategori" id="foto_kategori" class="file-upload-default"
|
||||
accept="image/*">
|
||||
|
||||
<!-- INPUT DISPLAY -->
|
||||
<div class="input-group col-xs-12">
|
||||
<input type="text" class="form-control file-upload-info" disabled
|
||||
placeholder="Upload Image">
|
||||
placeholder="Upload Foto">
|
||||
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<!-- PREVIEW FOTO LAMA -->
|
||||
@if (!empty($kategori->foto_kategori))
|
||||
<div class="mt-3">
|
||||
<small class="text-muted">Foto saat ini:</small><br>
|
||||
<img src="{{ asset('storage/' . $kategori->foto_kategori) }}" alt="Foto Kategori"
|
||||
width="120" class="img-thumbnail mt-1">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputCity1">City</label>
|
||||
<input type="text" class="form-control" id="exampleInputCity1"
|
||||
placeholder="Location">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleTextarea1">Textarea</label>
|
||||
<textarea class="form-control" id="exampleTextarea1" rows="4"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mr-2">Submit</button>
|
||||
<button class="btn btn-light">Cancel</button>
|
||||
|
||||
|
||||
<button class="btn btn-primary">Update</button>
|
||||
<a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,84 +6,54 @@
|
|||
<div class="col-lg-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<!-- Header card: Judul kiri, tombol kanan -->
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<div>
|
||||
<h4 class="card-title mb-0">Basic Table</h4>
|
||||
<p class="card-description mb-0">
|
||||
Add class <code>.table</code>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.tps.create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg"></i> Tambah
|
||||
<div class="d-flex justify-content-between mb-3">
|
||||
<h4 class="card-title">Kategori TPS</h4>
|
||||
<a href="{{ route('admin.kategori.create') }}" class="btn btn-primary">
|
||||
+ Tambah
|
||||
</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Tabel -->
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Profile</th>
|
||||
<th>VatNo.</th>
|
||||
<th>Created</th>
|
||||
<th>Status</th>
|
||||
<th>Nama Kategori</th>
|
||||
<th>Foto</th>
|
||||
<th>Deskripsi</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Jacob</td>
|
||||
<td>53275531</td>
|
||||
<td>12 May 2017</td>
|
||||
<td><label class="badge badge-danger">Pending</label></td>
|
||||
<td class="text-center">
|
||||
<a href="#" class="btn btn-warning btn-sm me-1" title="Edit">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-danger btn-sm" title="Hapus"
|
||||
onclick="return confirm('Yakin ingin menghapus data ini?')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Messsy</td>
|
||||
<td>53275532</td>
|
||||
<td>15 May 2017</td>
|
||||
<td><label class="badge badge-warning">In progress</label></td>
|
||||
<td class="text-center">
|
||||
<a href="#" class="btn btn-warning btn-sm me-1" title="Edit">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-danger btn-sm" title="Hapus"
|
||||
onclick="return confirm('Yakin ingin menghapus data ini?')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>John</td>
|
||||
<td>53275533</td>
|
||||
<td>14 May 2017</td>
|
||||
<td><label class="badge badge-info">Fixed</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Peter</td>
|
||||
<td>53275534</td>
|
||||
<td>16 May 2017</td>
|
||||
<td><label class="badge badge-success">Completed</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Dave</td>
|
||||
<td>53275535</td>
|
||||
<td>20 May 2017</td>
|
||||
<td><label class="badge badge-warning">In progress</label></td>
|
||||
</tr>
|
||||
@foreach ($kategori as $item)
|
||||
<tr>
|
||||
<td>{{ $item->nama_kategori }}</td>
|
||||
<td>
|
||||
@if ($item->foto_kategori)
|
||||
<img src="{{ asset('storage/' . $item->foto_kategori) }}" width="60">
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $item->deskripsi ?? '-' }}</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.kategori.edit', $item->id) }}"
|
||||
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) }}"
|
||||
method="POST" style="display:inline-block"
|
||||
onsubmit="return confirm('Yakin ingin menghapus data ini?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
|
||||
<button type="submit" class="btn btn-danger btn-sm" title="Hapus">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -61,15 +61,21 @@
|
|||
<nav class="sidebar sidebar-offcanvas" id="sidebar">
|
||||
<ul class="nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="index.html">
|
||||
<a class="nav-link" href="{{ route('admin.dashboard') }}">
|
||||
<i class="icon-grid menu-icon"></i>
|
||||
<span class="menu-title">Dashboard</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('admin.tps') }}">
|
||||
<a class="nav-link" href="{{ route('admin.tps.index') }}">
|
||||
<i class="icon-grid menu-icon"></i>
|
||||
<span class="menu-title">TPS</span>
|
||||
<span class="menu-title">Kelola TPS</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('admin.kategori.index') }}">
|
||||
<i class="icon-paper menu-icon"></i>
|
||||
<span class="menu-title">Kategori TPS</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
|
|
@ -231,6 +237,9 @@
|
|||
<!-- Custom js for this page-->
|
||||
<script src="{{ asset('assets/admin/js/dashboard.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/js/file-upload.js') }}"></script>
|
||||
|
||||
<!-- End custom js for this page-->
|
||||
</body>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,62 +1,89 @@
|
|||
@extends('admin.template')
|
||||
|
||||
@section('content')
|
||||
<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">Basic form elements</h4>
|
||||
<p class="card-description">
|
||||
Basic form elements
|
||||
</p>
|
||||
<form class="forms-sample">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputName1">Name</label>
|
||||
<input type="text" class="form-control" id="exampleInputName1" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail3">Email address</label>
|
||||
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputPassword4">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword4"
|
||||
placeholder="Password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleSelectGender">Gender</label>
|
||||
<select class="form-control" id="exampleSelectGender">
|
||||
<option>Male</option>
|
||||
<option>Female</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>File upload</label>
|
||||
<input type="file" name="img[]" class="file-upload-default">
|
||||
<div class="input-group col-xs-12">
|
||||
<input type="text" class="form-control file-upload-info" disabled
|
||||
placeholder="Upload Image">
|
||||
<span class="input-group-append">
|
||||
<button class="file-upload-browse btn btn-primary" type="button">Upload</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputCity1">City</label>
|
||||
<input type="text" class="form-control" id="exampleInputCity1"
|
||||
placeholder="Location">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleTextarea1">Textarea</label>
|
||||
<textarea class="form-control" id="exampleTextarea1" rows="4"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mr-2">Submit</button>
|
||||
<button class="btn btn-light">Cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
<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">Tambah TPS</h4>
|
||||
<p class="card-description">Form tambah data TPS</p>
|
||||
|
||||
<form action="{{ route('admin.tps.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<!-- NAMA TPS -->
|
||||
<div class="form-group">
|
||||
<label>Nama TPS</label>
|
||||
<input type="text" name="nama_tps" class="form-control"
|
||||
placeholder="Nama TPS" required>
|
||||
</div>
|
||||
|
||||
<!-- KATEGORI TPS -->
|
||||
<div class="form-group">
|
||||
<label>Kategori TPS</label>
|
||||
<select name="kategori_tps_id" class="form-control" required>
|
||||
<option value="">Pilih Kategori</option>
|
||||
@foreach ($kategori as $item)
|
||||
<option value="{{ $item->id }}">
|
||||
{{ $item->nama_kategori }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- TAHUN -->
|
||||
<div class="form-group">
|
||||
<label>Tahun Pembuatan</label>
|
||||
<input type="number" name="tahun_pembuatan" class="form-control"
|
||||
placeholder="Tahun Pembuatan" required>
|
||||
</div>
|
||||
|
||||
<!-- KAPASITAS -->
|
||||
<div class="form-group">
|
||||
<label>Kapasitas</label>
|
||||
<input type="text" name="kapasitas_tps" class="form-control"
|
||||
placeholder="Kapasitas TPS" required>
|
||||
</div>
|
||||
|
||||
<!-- STATUS -->
|
||||
<div class="form-group">
|
||||
<label>Status</label>
|
||||
<select name="status_tps" class="form-control" required>
|
||||
<option value="Aktif">Aktif</option>
|
||||
<option value="Non-Aktif">Non-Aktif</option>
|
||||
<option value="Pembangunan">Pembangunan</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- LATITUDE -->
|
||||
<div class="form-group">
|
||||
<label>Latitude</label>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<!-- FOTO -->
|
||||
<div class="form-group">
|
||||
<label>Foto TPS</label>
|
||||
<input type="file" name="foto_tps"
|
||||
class="form-control" accept="image/*">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mr-2">Simpan</button>
|
||||
<a href="{{ route('admin.tps.index') }}" class="btn btn-light">Batal</a>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -1,91 +1,104 @@
|
|||
@extends('admin.template')
|
||||
|
||||
@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="d-flex justify-content-between align-items-center mb-3">
|
||||
<div>
|
||||
<h4 class="card-title mb-0">Tambah TPS</h4>
|
||||
<p class="card-description mb-0">
|
||||
Form tambah data Tempat Pengelolaan Sampah (TPS)
|
||||
</p>
|
||||
</div>
|
||||
<a href="{{ route('admin.tps.create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg"></i> Tambah
|
||||
</a>
|
||||
</div>
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<!-- Tabel -->
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nama</th>
|
||||
<th>VatNo.</th>
|
||||
<th>Created</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Jacob</td>
|
||||
<td>53275531</td>
|
||||
<td>12 May 2017</td>
|
||||
<td><label class="badge badge-danger">Pending</label></td>
|
||||
<td class="text-center">
|
||||
<a href="{{ route('admin.tps.edit') }}" class="btn btn-warning btn-sm me-1" title="Edit">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-danger btn-sm" title="Hapus"
|
||||
onclick="return confirm('Yakin ingin menghapus data ini?')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Messsy</td>
|
||||
<td>53275532</td>
|
||||
<td>15 May 2017</td>
|
||||
<td><label class="badge badge-warning">In progress</label></td>
|
||||
<td class="text-center">
|
||||
<a href="#" class="btn btn-warning btn-sm me-1" title="Edit">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-danger btn-sm" title="Hapus"
|
||||
onclick="return confirm('Yakin ingin menghapus data ini?')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>John</td>
|
||||
<td>53275533</td>
|
||||
<td>14 May 2017</td>
|
||||
<td><label class="badge badge-info">Fixed</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Peter</td>
|
||||
<td>53275534</td>
|
||||
<td>16 May 2017</td>
|
||||
<td><label class="badge badge-success">Completed</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Dave</td>
|
||||
<td>53275535</td>
|
||||
<td>20 May 2017</td>
|
||||
<td><label class="badge badge-warning">In progress</label></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<div>
|
||||
<h4 class="card-title mb-0">Data TPS</h4>
|
||||
<p class="card-description mb-0">
|
||||
Daftar Tempat Pengelolaan Sampah (TPS)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.tps.create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg"></i> Tambah
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nama TPS</th>
|
||||
<th>Kategori</th>
|
||||
<th>Foto</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@forelse ($tps as $item)
|
||||
<tr>
|
||||
<!-- NAMA -->
|
||||
<td>{{ $item->nama_tps }}</td>
|
||||
|
||||
<!-- KATEGORI -->
|
||||
<td>
|
||||
{{ $item->kategori->nama_kategori ?? '-' }}
|
||||
</td>
|
||||
|
||||
<!-- FOTO -->
|
||||
<td>
|
||||
@if ($item->foto_tps)
|
||||
<img src="{{ asset('storage/' . $item->foto_tps) }}"
|
||||
alt="Foto TPS"
|
||||
height="60"
|
||||
style="border-radius:6px">
|
||||
@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>
|
||||
@else
|
||||
<label class="badge badge-warning">Pembangunan</label>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<!-- AKSI -->
|
||||
<td class="text-center">
|
||||
<a href="{{ route('admin.tps.edit', $item->id) }}"
|
||||
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;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger btn-sm"
|
||||
onclick="return confirm('Yakin ingin menghapus data ini?')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
Data TPS belum tersedia
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use App\Http\Controllers\SigController;
|
||||
use App\Http\Controllers\AboutController;
|
||||
use App\Http\Controllers\Admin\DashboardController;
|
||||
use App\Http\Controllers\Admin\KategoriTpsController;
|
||||
use App\Http\Controllers\Admin\LoginController;
|
||||
use App\Http\Controllers\Admin\TpsController;
|
||||
use App\Http\Controllers\IndexController;
|
||||
|
|
@ -10,39 +11,59 @@
|
|||
use App\Http\Controllers\KontakController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/index', [IndexController::class, 'index'])->name('user.index');
|
||||
Route::get('/about', [AboutController::class, 'index'])->name('user.about');
|
||||
Route::get('/about-tps', [AboutController::class, 'tps'])->name('user.about-tps');
|
||||
Route::get('/sig-tps', [SigController::class, 'index'])
|
||||
->name('user.sig-tps');
|
||||
Route::get('/tps/{id}', [SigController::class, 'show'])
|
||||
->name('user.detail-tps');
|
||||
Route::get('/aduan-tps', [AduanController::class, 'index'])->name('user.aduan-tps');
|
||||
Route::get('/kontak', [KontakController::class, 'index'])->name('user.kontak');
|
||||
|
||||
// Route::get('/dashboard', [DashboardController::class, 'index'])->name('admin.dashboard');
|
||||
Route::get('/tps-admin', [TpsController::class, 'index'])->name('admin.tps');
|
||||
Route::get('/tps-admin/create', [TpsController::class, 'create'])->name('admin.tps.create');
|
||||
Route::get('/tps-admin/edit', [TpsController::class, 'edit'])->name('admin.tps.edit');
|
||||
Route::get('/login', [LoginController::class, 'index'])->name('admin.login');
|
||||
Route::post('/login', [LoginController::class, 'authenticate'])->name('admin.authenticate');
|
||||
Route::post('/logout', [LoginController::class, 'logout'])->name('admin.logout');
|
||||
|
||||
Route::get('/admin/login', [LoginController::class, 'index'])
|
||||
->name('admin.login');
|
||||
|
||||
Route::post('/admin/login', [LoginController::class, 'process'])
|
||||
->name('admin.login.process');
|
||||
|
||||
Route::post('/admin/logout', [LoginController::class, 'logout'])
|
||||
->name('admin.logout');
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/admin/dashboard', [DashboardController::class, 'index'])
|
||||
->name('admin.dashboard');
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ROUTE USER / PUBLIK
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Route::get('/index', [IndexController::class, 'index'])->name('user.index');
|
||||
Route::get('/about', [AboutController::class, 'index'])->name('user.about');
|
||||
Route::get('/about-tps', [AboutController::class, 'tps'])->name('user.about-tps');
|
||||
|
||||
Route::get('/sig-tps', [SigController::class, 'index'])->name('user.sig-tps');
|
||||
Route::get('/tps/{id}', [SigController::class, 'show'])->name('user.detail-tps');
|
||||
|
||||
Route::get('/aduan-tps', [AduanController::class, 'index'])->name('user.aduan-tps');
|
||||
Route::get('/kontak', [KontakController::class, 'index'])->name('user.kontak');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ROUTE AUTH ADMIN
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Route::get('/admin/login', [LoginController::class, 'index'])->name('admin.login');
|
||||
Route::post('/admin/login', [LoginController::class, 'process'])->name('admin.login.process');
|
||||
Route::post('/admin/logout', [LoginController::class, 'logout'])->name('admin.logout');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ROUTE ADMIN (PROTECTED)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Route::middleware(['auth'])->prefix('admin')->name('admin.')->group(function () {
|
||||
|
||||
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
||||
|
||||
// TPS ADMIN
|
||||
Route::get('/tps', [TpsController::class, 'index'])->name('tps.index');
|
||||
Route::get('/tps/create', [TpsController::class, 'create'])->name('tps.create');
|
||||
Route::post('/tps', [TpsController::class, 'store'])->name('tps.store');
|
||||
Route::get('/tps/{id}/edit', [TpsController::class, 'edit'])->name('tps.edit');
|
||||
Route::put('/tps/{id}', [TpsController::class, 'update'])->name('tps.update');
|
||||
Route::delete('/tps/{id}', [TpsController::class, 'destroy'])->name('tps.destroy');
|
||||
|
||||
// KATEGORI TPS ADMIN
|
||||
Route::get('/kategori-tps', [KategoriTpsController::class, 'index'])->name('kategori.index');
|
||||
Route::get('/kategori-tps/create', [KategoriTpsController::class, 'create'])->name('kategori.create');
|
||||
Route::post('/kategori-tps', [KategoriTpsController::class, 'store'])->name('kategori.store');
|
||||
Route::get('/kategori-tps/{id}/edit', [KategoriTpsController::class, 'edit'])->name('kategori.edit');
|
||||
Route::put('/kategori-tps/{id}', [KategoriTpsController::class, 'update'])->name('kategori.update');
|
||||
Route::delete('/kategori-tps/{id}', [KategoriTpsController::class, 'destroy'])->name('kategori.destroy');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue