add aduan
This commit is contained in:
parent
8b2047f41d
commit
98e112dec2
|
|
@ -3,12 +3,61 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\AduanTps;
|
||||||
|
use App\Models\LokasiTps;
|
||||||
|
|
||||||
class AduanController extends Controller
|
class AduanController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$title = 'User Aduan';
|
$title = 'Aduan TPS';
|
||||||
return view('user.aduan-tps', compact('title'));
|
|
||||||
|
// TPS terpilih (jika dari SIG / detail)
|
||||||
|
$tps = null;
|
||||||
|
if ($request->filled('tps_id')) {
|
||||||
|
$tps = LokasiTps::with('kategori')
|
||||||
|
->where('id_tps', $request->tps_id)
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
// List TPS untuk dropdown (jika dari navbar)
|
||||||
|
$listTps = LokasiTps::orderBy('nama_tps')->get();
|
||||||
|
|
||||||
|
return view('user.aduan-tps', compact(
|
||||||
|
'title',
|
||||||
|
'tps',
|
||||||
|
'listTps'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'lokasi_tps_id' => 'required|exists:lokasi_tps,id_tps',
|
||||||
|
'nama_pelapor' => 'required',
|
||||||
|
'alamat_pelapor'=> 'required',
|
||||||
|
'no_pelapor' => 'required',
|
||||||
|
'isi_aduan' => 'required',
|
||||||
|
'bukti_foto' => 'nullable|image|max:2048'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$foto = null;
|
||||||
|
if ($request->hasFile('bukti_foto')) {
|
||||||
|
$foto = $request->file('bukti_foto')->store('aduan', 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
AduanTps::create([
|
||||||
|
'lokasi_tps_id' => $request->lokasi_tps_id,
|
||||||
|
'nama_pelapor' => $request->nama_pelapor,
|
||||||
|
'alamat_pelapor'=> $request->alamat_pelapor,
|
||||||
|
'no_pelapor' => $request->no_pelapor,
|
||||||
|
'isi_aduan' => $request->isi_aduan,
|
||||||
|
'tanggal_aduan' => now(),
|
||||||
|
'bukti_foto' => $foto
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('user.aduan')
|
||||||
|
->with('success', 'Aduan berhasil dikirim');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,40 +21,47 @@
|
||||||
<div class="row gy-5 gx-lg-5">
|
<div class="row gy-5 gx-lg-5">
|
||||||
|
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<h3>Get in touch</h3>
|
|
||||||
<p>Et id eius voluptates atque nihil voluptatem enim in tempore minima sit ad mollitia commodi
|
|
||||||
minus.</p>
|
|
||||||
|
|
||||||
<div class="info-item d-flex">
|
<h3 class="mb-3">TPS yang Diadukan</h3>
|
||||||
<i class="bi bi-geo-alt flex-shrink-0"></i>
|
|
||||||
<div>
|
{{-- FOTO TPS --}}
|
||||||
<h4>Location:</h4>
|
<div class="mb-3">
|
||||||
<p>A108 Adam Street, New York, NY 535022</p>
|
<img id="foto-tps"
|
||||||
|
src="{{ $tps && $tps->foto_tps ? asset('storage/' . $tps->foto_tps) : asset('assets/user/img/no-image.png') }}"
|
||||||
|
class="img-fluid w-100" style="object-fit:cover; max-height:220px;" alt="Foto TPS">
|
||||||
</div>
|
</div>
|
||||||
</div><!-- End Info Item -->
|
|
||||||
|
|
||||||
<div class="info-item d-flex">
|
{{-- INFO TPS --}}
|
||||||
<i class="bi bi-envelope flex-shrink-0"></i>
|
<div id="info-tps">
|
||||||
<div>
|
@if ($tps)
|
||||||
<h4>Email:</h4>
|
<p class="mb-1"><strong>{{ $tps->nama_tps }}</strong></p>
|
||||||
<p>info@example.com</p>
|
<p class="mb-1 text-muted">{{ $tps->alamat_tps }}</p>
|
||||||
</div>
|
<input type="hidden" name="lokasi_tps_id" value="{{ $tps->id_tps }}">
|
||||||
</div><!-- End Info Item -->
|
@else
|
||||||
|
<p class="text-muted mb-2">
|
||||||
<div class="info-item d-flex">
|
Silakan pilih TPS yang akan diadukan
|
||||||
<i class="bi bi-phone flex-shrink-0"></i>
|
</p>
|
||||||
<div>
|
|
||||||
<h4>Call:</h4>
|
|
||||||
<p>+1 5589 55488 55</p>
|
|
||||||
</div>
|
|
||||||
</div><!-- End Info Item -->
|
|
||||||
|
|
||||||
|
<select name="lokasi_tps_id" id="pilih-tps" class="form-select" required>
|
||||||
|
<option value="">-- Pilih TPS --</option>
|
||||||
|
@foreach ($listTps as $item)
|
||||||
|
<option value="{{ $item->id_tps }}" data-nama="{{ $item->nama_tps }}"
|
||||||
|
data-alamat="{{ $item->alamat_tps }}"
|
||||||
|
data-foto="{{ $item->foto_tps ? asset('storage/' . $item->foto_tps) : asset('assets/user/img/no-image.png') }}">
|
||||||
|
{{ $item->nama_tps }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
<form action="forms/contact.php" method="post" role="form" class="php-email-form">
|
<form action="forms/contact.php" method="post" role="form" class="php-email-form">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -88,4 +95,29 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const selectTps = document.getElementById('pilih-tps');
|
||||||
|
|
||||||
|
if (selectTps) {
|
||||||
|
selectTps.addEventListener('change', function() {
|
||||||
|
const option = this.options[this.selectedIndex];
|
||||||
|
|
||||||
|
const foto = option.getAttribute('data-foto');
|
||||||
|
const nama = option.getAttribute('data-nama');
|
||||||
|
const alamat = option.getAttribute('data-alamat');
|
||||||
|
|
||||||
|
// Ganti foto
|
||||||
|
document.getElementById('foto-tps').src = foto;
|
||||||
|
|
||||||
|
// Ganti info teks
|
||||||
|
document.getElementById('info-tps').insertAdjacentHTML('beforeend', `
|
||||||
|
<p class="mt-3 mb-1"><strong>${nama}</strong></p>
|
||||||
|
<p class="text-muted">${alamat}</p>
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class="img-fluid" alt="">
|
||||||
Laporkan jika TPS bermasalah atau penuh
|
Laporkan jika TPS bermasalah atau penuh
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
<a href="{{ route('user.aduan-tps', $tps->id) }}"
|
<a href="{{ route('user.aduan', ['tps_id' => $tps->id_tps]) }}"
|
||||||
class="btn btn-danger btn-sm d-flex align-items-center">
|
class="btn btn-danger btn-sm d-flex align-items-center">
|
||||||
Adukan TPS
|
Adukan TPS
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ function markerIcon(color) {
|
||||||
Detail TPS
|
Detail TPS
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="/aduan/create/${tps.id_tps}"
|
<a href="{{ url('aduan') }}/${tps.id_tps}"
|
||||||
style="flex:1; text-align:center; padding:6px 8px; background:#dc3545; color:#fff; border-radius:6px; font-size:13px; text-decoration:none;">
|
style="flex:1; text-align:center; padding:6px 8px; background:#dc3545; color:#fff; border-radius:6px; font-size:13px; text-decoration:none;">
|
||||||
Aduan
|
Aduan
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="{{ route('user.sig-tps') }}">Sebaran TPS</a></li>
|
<li><a href="{{ route('user.sig-tps') }}">Sebaran TPS</a></li>
|
||||||
<li><a href="{{ route('user.aduan-tps') }}">Aduan TPS</a></li>
|
<li><a href="{{ route('user.aduan') }}">Aduan TPS</a></li>
|
||||||
<li><a href="{{ route('user.kontak') }}">Kontak</a></li>
|
<li><a href="{{ route('user.kontak') }}">Kontak</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<i class="mobile-nav-toggle d-xl-none bi bi-list"></i>
|
<i class="mobile-nav-toggle d-xl-none bi bi-list"></i>
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@
|
||||||
Route::get('/sig-tps', [SigController::class, 'index'])->name('user.sig-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('/tps/{id}', [SigController::class, 'show'])->name('user.detail-tps');
|
||||||
|
|
||||||
Route::get('/aduan-tps', [AduanController::class, 'index'])->name('user.aduan-tps');
|
Route::get('/aduan-tps', [AduanController::class, 'index'])->name('user.aduan');
|
||||||
|
Route::post('/aduan-tps', [AduanController::class, 'store'])->name('user.aduan.store');
|
||||||
Route::get('/kontak', [KontakController::class, 'index'])->name('user.kontak');
|
Route::get('/kontak', [KontakController::class, 'index'])->name('user.kontak');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue