pembaruan admin
This commit is contained in:
parent
7100ed2342
commit
217fb8907e
|
|
@ -13,7 +13,6 @@ public function index()
|
||||||
{
|
{
|
||||||
$title = 'Kategori TPS';
|
$title = 'Kategori TPS';
|
||||||
$kategori = KategoriTps::all();
|
$kategori = KategoriTps::all();
|
||||||
|
|
||||||
return view('admin.kategori-tps.index', compact('title', 'kategori'));
|
return view('admin.kategori-tps.index', compact('title', 'kategori'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,30 +24,38 @@ public function create()
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request->validate([
|
$data = $request->validate(
|
||||||
|
[
|
||||||
'nama_kategori' => 'required|string|max:100',
|
'nama_kategori' => 'required|string|max:100',
|
||||||
'kepanjangan_kategori' => 'nullable|string|max:255',
|
'kepanjangan_kategori' => 'required|string|max:255',
|
||||||
'deskripsi' => 'nullable|string',
|
'deskripsi' => 'required|string',
|
||||||
'foto_kategori' => 'nullable|image|mimes:jpg,jpeg,png|max:2048'
|
'foto_kategori' => 'required|image|mimes:jpg,jpeg,png|max:2048',
|
||||||
]);
|
],
|
||||||
|
[
|
||||||
|
'nama_kategori.required' => 'Nama kategori wajib diisi',
|
||||||
|
'kepanjangan_kategori.required' => 'Kepanjangan kategori wajib diisi',
|
||||||
|
'deskripsi.required' => 'Deskripsi kategori wajib diisi',
|
||||||
|
'foto_kategori.required' => 'Foto kategori wajib diunggah',
|
||||||
|
'foto_kategori.image' => 'File harus berupa gambar',
|
||||||
|
'foto_kategori.mimes' => 'Format gambar harus JPG, JPEG, atau PNG',
|
||||||
|
'foto_kategori.max' => 'Ukuran gambar maksimal 2 MB',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
if ($request->hasFile('foto_kategori')) {
|
|
||||||
$data['foto_kategori'] = $request->file('foto_kategori')
|
$data['foto_kategori'] = $request->file('foto_kategori')
|
||||||
->store('kategori', 'public');
|
->store('kategori', 'public');
|
||||||
}
|
|
||||||
|
|
||||||
KategoriTps::create($data);
|
KategoriTps::create($data);
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('admin.kategori.index')
|
->route('admin.kategori.index')
|
||||||
->with('success', 'Kategori berhasil ditambahkan');
|
->with('success', 'Kategori TPS berhasil ditambahkan');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$title = 'Edit Kategori TPS';
|
$title = 'Edit Kategori TPS';
|
||||||
$kategori = KategoriTps::findOrFail($id);
|
$kategori = KategoriTps::findOrFail($id);
|
||||||
|
|
||||||
return view('admin.kategori-tps.edit', compact('title', 'kategori'));
|
return view('admin.kategori-tps.edit', compact('title', 'kategori'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,12 +63,22 @@ public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$kategori = KategoriTps::findOrFail($id);
|
$kategori = KategoriTps::findOrFail($id);
|
||||||
|
|
||||||
$data = $request->validate([
|
$data = $request->validate(
|
||||||
|
[
|
||||||
'nama_kategori' => 'required|string|max:100',
|
'nama_kategori' => 'required|string|max:100',
|
||||||
'kepanjangan_kategori' => 'nullable|string|max:255',
|
'kepanjangan_kategori' => 'required|string|max:255',
|
||||||
'deskripsi' => 'nullable|string',
|
'deskripsi' => 'required|string',
|
||||||
'foto_kategori' => 'nullable|image|mimes:jpg,jpeg,png|max:4096'
|
'foto_kategori' => 'nullable|image|mimes:jpg,jpeg,png|max:4096',
|
||||||
]);
|
],
|
||||||
|
[
|
||||||
|
'nama_kategori.required' => 'Nama kategori wajib diisi',
|
||||||
|
'kepanjangan_kategori.required' => 'Kepanjangan kategori wajib diisi',
|
||||||
|
'deskripsi.required' => 'Deskripsi kategori wajib diisi',
|
||||||
|
'foto_kategori.image' => 'File harus berupa gambar',
|
||||||
|
'foto_kategori.mimes' => 'Format gambar harus JPG, JPEG, atau PNG',
|
||||||
|
'foto_kategori.max' => 'Ukuran gambar maksimal 4 MB',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
if ($request->hasFile('foto_kategori')) {
|
if ($request->hasFile('foto_kategori')) {
|
||||||
if ($kategori->foto_kategori) {
|
if ($kategori->foto_kategori) {
|
||||||
|
|
@ -76,7 +93,7 @@ public function update(Request $request, $id)
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('admin.kategori.index')
|
->route('admin.kategori.index')
|
||||||
->with('success', 'Kategori berhasil diperbarui');
|
->with('success', 'Kategori TPS berhasil diperbarui');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
|
|
@ -91,6 +108,6 @@ public function destroy($id)
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('admin.kategori.index')
|
->route('admin.kategori.index')
|
||||||
->with('success', 'Kategori berhasil dihapus');
|
->with('success', 'Kategori TPS berhasil dihapus');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
class ProfilController extends Controller
|
class ProfilController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -22,19 +23,54 @@ public function update(Request $request)
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255',
|
||||||
'username' => 'required|string|max:100',
|
'username' => 'required|string|max:100',
|
||||||
|
'foto' => 'nullable|image|mimes:jpg,jpeg,png|max:2048',
|
||||||
'password' => 'nullable|min:6|confirmed',
|
'password' => 'nullable|min:6|confirmed',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ======================
|
||||||
|
// UPDATE DATA DASAR
|
||||||
|
// ======================
|
||||||
$admin->name = $request->name;
|
$admin->name = $request->name;
|
||||||
$admin->username = $request->username;
|
$admin->username = $request->username;
|
||||||
|
|
||||||
|
// ======================
|
||||||
|
// PROSES FOTO
|
||||||
|
// ======================
|
||||||
|
if ($request->hasFile('foto')) {
|
||||||
|
|
||||||
|
$path = public_path('assets/admin/foto-admin');
|
||||||
|
|
||||||
|
// buat folder kalau belum ada
|
||||||
|
if (!File::exists($path)) {
|
||||||
|
File::makeDirectory($path, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// hapus foto lama
|
||||||
|
if ($admin->foto && File::exists($path.'/'.$admin->foto)) {
|
||||||
|
File::delete($path.'/'.$admin->foto);
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $request->file('foto');
|
||||||
|
$namaFoto = time().'_'.uniqid().'.'.$file->getClientOriginalExtension();
|
||||||
|
|
||||||
|
// SIMPAN FOTO (INI KUNCI)
|
||||||
|
$file->move($path, $namaFoto);
|
||||||
|
|
||||||
|
// simpan ke DB
|
||||||
|
$admin->foto = $namaFoto;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================
|
||||||
|
// PASSWORD
|
||||||
|
// ======================
|
||||||
if ($request->filled('password')) {
|
if ($request->filled('password')) {
|
||||||
$admin->password = Hash::make($request->password);
|
$admin->password = Hash::make($request->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin->save();
|
$admin->save();
|
||||||
|
|
||||||
return redirect()->route('admin.profil')
|
return redirect()
|
||||||
|
->route('admin.profil')
|
||||||
->with('success', 'Profil berhasil diperbarui');
|
->with('success', 'Profil berhasil diperbarui');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
use App\Models\Sampah;
|
use App\Models\Sampah;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class SampahController extends Controller
|
class SampahController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -14,7 +15,9 @@ public function index()
|
||||||
{
|
{
|
||||||
$title = 'Data Sampah';
|
$title = 'Data Sampah';
|
||||||
|
|
||||||
$sampah = Sampah::with('user')->orderBy('tahun', 'desc')->get();
|
$sampah = Sampah::with('user')
|
||||||
|
->orderBy('tahun', 'desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
return view('admin.sampah.index', compact('title', 'sampah'));
|
return view('admin.sampah.index', compact('title', 'sampah'));
|
||||||
}
|
}
|
||||||
|
|
@ -27,14 +30,49 @@ public function create()
|
||||||
return view('admin.sampah.create', compact('title', 'users'));
|
return view('admin.sampah.create', compact('title', 'users'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================================
|
||||||
|
STORE (TAMBAH DATA)
|
||||||
|
====================================================== */
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$validator = Validator::make(
|
||||||
'tahun' => 'required|numeric',
|
$request->all(),
|
||||||
'total_sampah' => 'required|numeric',
|
[
|
||||||
'total_kelola' => 'required|numeric',
|
'tahun' => 'required|digits:4',
|
||||||
'total_daur_ulang' => 'required|numeric',
|
'total_sampah' => 'required|numeric|min:0',
|
||||||
]);
|
'total_kelola' => 'required|numeric|min:0',
|
||||||
|
'total_daur_ulang' => 'required|numeric|min:0',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'tahun.required' => 'Tahun wajib diisi.',
|
||||||
|
'tahun.digits' => 'Tahun harus 4 digit (contoh: 2023).',
|
||||||
|
|
||||||
|
'total_sampah.required' => 'Total sampah wajib diisi.',
|
||||||
|
'total_sampah.numeric' => 'Total sampah harus berupa angka.',
|
||||||
|
'total_sampah.min' => 'Total sampah tidak boleh negatif.',
|
||||||
|
|
||||||
|
'total_kelola.required' => 'Total kelola wajib diisi.',
|
||||||
|
'total_kelola.numeric' => 'Total kelola harus berupa angka.',
|
||||||
|
'total_kelola.min' => 'Total kelola tidak boleh negatif.',
|
||||||
|
|
||||||
|
'total_daur_ulang.required' => 'Total daur ulang wajib diisi.',
|
||||||
|
'total_daur_ulang.numeric' => 'Total daur ulang harus berupa angka.',
|
||||||
|
'total_daur_ulang.min' => 'Total daur ulang tidak boleh negatif.',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return back()->withErrors($validator)->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
// VALIDASI LOGIKA DATA
|
||||||
|
if (($request->total_kelola + $request->total_daur_ulang) > $request->total_sampah) {
|
||||||
|
return back()
|
||||||
|
->withErrors([
|
||||||
|
'total_kelola' => 'Jumlah kelola + daur ulang tidak boleh melebihi total sampah.',
|
||||||
|
])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
$sisa_sampah = $request->total_sampah
|
$sisa_sampah = $request->total_sampah
|
||||||
- ($request->total_kelola + $request->total_daur_ulang);
|
- ($request->total_kelola + $request->total_daur_ulang);
|
||||||
|
|
@ -49,7 +87,7 @@ public function store(Request $request)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect()->route('admin.sampah.index')
|
return redirect()->route('admin.sampah.index')
|
||||||
->with('success', 'Data sampah berhasil ditambahkan');
|
->with('success', 'Data sampah berhasil ditambahkan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
|
|
@ -61,17 +99,52 @@ public function edit($id)
|
||||||
return view('admin.sampah.edit', compact('title', 'sampah', 'users'));
|
return view('admin.sampah.edit', compact('title', 'sampah', 'users'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================================
|
||||||
|
UPDATE (EDIT DATA)
|
||||||
|
====================================================== */
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$sampah = Sampah::findOrFail($id);
|
$sampah = Sampah::findOrFail($id);
|
||||||
|
|
||||||
$request->validate([
|
$validator = Validator::make(
|
||||||
|
$request->all(),
|
||||||
|
[
|
||||||
'user_id' => 'required|exists:users,id',
|
'user_id' => 'required|exists:users,id',
|
||||||
'tahun' => 'required|numeric',
|
'tahun' => 'required|digits:4',
|
||||||
'total_sampah' => 'required|numeric',
|
'total_sampah' => 'required|numeric|min:0',
|
||||||
'total_kelola' => 'required|numeric',
|
'total_kelola' => 'required|numeric|min:0',
|
||||||
'total_daur_ulang' => 'required|numeric',
|
'total_daur_ulang' => 'required|numeric|min:0',
|
||||||
]);
|
],
|
||||||
|
[
|
||||||
|
'user_id.required' => 'Pengguna wajib dipilih.',
|
||||||
|
'user_id.exists' => 'Pengguna tidak valid.',
|
||||||
|
|
||||||
|
'tahun.required' => 'Tahun wajib diisi.',
|
||||||
|
'tahun.digits' => 'Tahun harus 4 digit.',
|
||||||
|
|
||||||
|
'total_sampah.required' => 'Total sampah wajib diisi.',
|
||||||
|
'total_sampah.numeric' => 'Total sampah harus berupa angka.',
|
||||||
|
|
||||||
|
'total_kelola.required' => 'Total kelola wajib diisi.',
|
||||||
|
'total_kelola.numeric' => 'Total kelola harus berupa angka.',
|
||||||
|
|
||||||
|
'total_daur_ulang.required' => 'Total daur ulang wajib diisi.',
|
||||||
|
'total_daur_ulang.numeric' => 'Total daur ulang harus berupa angka.',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return back()->withErrors($validator)->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
// VALIDASI LOGIKA DATA
|
||||||
|
if (($request->total_kelola + $request->total_daur_ulang) > $request->total_sampah) {
|
||||||
|
return back()
|
||||||
|
->withErrors([
|
||||||
|
'total_kelola' => 'Jumlah kelola + daur ulang tidak boleh melebihi total sampah.',
|
||||||
|
])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
$sisa_sampah = $request->total_sampah
|
$sisa_sampah = $request->total_sampah
|
||||||
- ($request->total_kelola + $request->total_daur_ulang);
|
- ($request->total_kelola + $request->total_daur_ulang);
|
||||||
|
|
@ -86,7 +159,7 @@ public function update(Request $request, $id)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect()->route('admin.sampah.index')
|
return redirect()->route('admin.sampah.index')
|
||||||
->with('success', 'Data sampah berhasil diperbarui');
|
->with('success', 'Data sampah berhasil diperbarui.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
|
|
@ -95,6 +168,6 @@ public function destroy($id)
|
||||||
$sampah->delete();
|
$sampah->delete();
|
||||||
|
|
||||||
return redirect()->route('admin.sampah.index')
|
return redirect()->route('admin.sampah.index')
|
||||||
->with('success', 'Data sampah berhasil dihapus');
|
->with('success', 'Data sampah berhasil dihapus.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
use App\Models\LokasiTps;
|
use App\Models\LokasiTps;
|
||||||
use App\Models\KategoriTps;
|
use App\Models\KategoriTps;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class TpsController extends Controller
|
class TpsController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -28,28 +29,24 @@ public function create()
|
||||||
return view('admin.tps.create', compact('title', 'kategori'));
|
return view('admin.tps.create', compact('title', 'kategori'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| KONVERSI KOORDINAT (DECIMAL / DMS)
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
private function convertToDecimal($coordinate)
|
private function convertToDecimal($coordinate)
|
||||||
{
|
{
|
||||||
if (is_numeric($coordinate)) {
|
if (is_numeric($coordinate)) {
|
||||||
return (float) $coordinate;
|
return (float) $coordinate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$coordinate) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$coordinate = html_entity_decode($coordinate);
|
$coordinate = html_entity_decode($coordinate);
|
||||||
$coordinate = strtoupper(trim($coordinate));
|
$coordinate = strtoupper(trim($coordinate));
|
||||||
$coordinate = str_replace(['°', "'", '"'], [' ', ' ', ' '], $coordinate);
|
$coordinate = str_replace(['°', "'", '"'], [' ', ' ', ' '], $coordinate);
|
||||||
|
|
||||||
preg_match('/([NSEW])/', $coordinate, $dir);
|
preg_match('/([NSEW])/', $coordinate, $dir);
|
||||||
if (!$dir) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
preg_match_all('/\d+(\.\d+)?/', $coordinate, $numbers);
|
preg_match_all('/\d+(\.\d+)?/', $coordinate, $numbers);
|
||||||
if (count($numbers[0]) < 3) {
|
|
||||||
|
if (!$dir || count($numbers[0]) < 3) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,15 +60,10 @@ private function convertToDecimal($coordinate)
|
||||||
return $decimal;
|
return $decimal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| STORE (CREATE)
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
// VALIDASI DASAR + PESAN CUSTOM
|
$validator = Validator::make(
|
||||||
$request->validate(
|
$request->all(),
|
||||||
[
|
[
|
||||||
'kategori_tps_id' => 'required|exists:kategori_tps,id_kategori_tps',
|
'kategori_tps_id' => 'required|exists:kategori_tps,id_kategori_tps',
|
||||||
'nama_tps' => 'required|string|max:255',
|
'nama_tps' => 'required|string|max:255',
|
||||||
|
|
@ -81,7 +73,7 @@ public function store(Request $request)
|
||||||
'kapasitas_tps' => 'required|integer|min:1',
|
'kapasitas_tps' => 'required|integer|min:1',
|
||||||
'latitude' => 'required',
|
'latitude' => 'required',
|
||||||
'longitude' => 'required',
|
'longitude' => 'required',
|
||||||
'foto_tps' => 'nullable|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.required' => 'Kategori TPS wajib dipilih.',
|
||||||
|
|
@ -94,7 +86,7 @@ public function store(Request $request)
|
||||||
'status_tps.in' => 'Status TPS tidak valid.',
|
'status_tps.in' => 'Status TPS tidak valid.',
|
||||||
|
|
||||||
'tahun_pembuatan.required' => 'Tahun pembuatan wajib diisi.',
|
'tahun_pembuatan.required' => 'Tahun pembuatan wajib diisi.',
|
||||||
'tahun_pembuatan.digits' => 'Tahun pembuatan harus 4 digit (contoh: 2022).',
|
'tahun_pembuatan.digits' => 'Tahun pembuatan harus 4 digit.',
|
||||||
|
|
||||||
'kapasitas_tps.required' => 'Kapasitas TPS wajib diisi.',
|
'kapasitas_tps.required' => 'Kapasitas TPS wajib diisi.',
|
||||||
'kapasitas_tps.integer' => 'Kapasitas TPS harus berupa angka.',
|
'kapasitas_tps.integer' => 'Kapasitas TPS harus berupa angka.',
|
||||||
|
|
@ -103,33 +95,32 @@ public function store(Request $request)
|
||||||
'latitude.required' => 'Latitude wajib diisi.',
|
'latitude.required' => 'Latitude wajib diisi.',
|
||||||
'longitude.required' => 'Longitude wajib diisi.',
|
'longitude.required' => 'Longitude wajib diisi.',
|
||||||
|
|
||||||
|
'foto_tps.required' => 'Foto TPS wajib diunggah.',
|
||||||
'foto_tps.image' => 'Foto TPS harus berupa gambar.',
|
'foto_tps.image' => 'Foto TPS harus berupa gambar.',
|
||||||
'foto_tps.mimes' => 'Format foto TPS harus jpg, jpeg, atau png.',
|
'foto_tps.mimes' => 'Format foto harus jpg, jpeg, atau png.',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// VALIDASI KOORDINAT (TIDAK DOBEL ERROR)
|
if ($validator->fails()) {
|
||||||
|
return back()->withErrors($validator)->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
$latitude = $this->convertToDecimal($request->latitude);
|
$latitude = $this->convertToDecimal($request->latitude);
|
||||||
$longitude = $this->convertToDecimal($request->longitude);
|
$longitude = $this->convertToDecimal($request->longitude);
|
||||||
|
|
||||||
$errors = [];
|
|
||||||
|
|
||||||
if ($latitude === null || $latitude < -90 || $latitude > 90) {
|
if ($latitude === null || $latitude < -90 || $latitude > 90) {
|
||||||
$errors['latitude'] = 'Latitude tidak valid. Contoh: -7.623 atau 7.623';
|
$validator->errors()->add('latitude', 'Latitude tidak valid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($longitude === null || $longitude < -180 || $longitude > 180) {
|
if ($longitude === null || $longitude < -180 || $longitude > 180) {
|
||||||
$errors['longitude'] = 'Longitude tidak valid. Contoh: 111.980 atau -111.980';
|
$validator->errors()->add('longitude', 'Longitude tidak valid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($errors)) {
|
if ($validator->fails()) {
|
||||||
return back()->withErrors($errors)->withInput();
|
return back()->withErrors($validator)->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// UPLOAD FOTO
|
$foto = $request->file('foto_tps')->store('foto-tps', 'public');
|
||||||
$foto = $request->hasFile('foto_tps')
|
|
||||||
? $request->file('foto_tps')->store('foto-tps', 'public')
|
|
||||||
: null;
|
|
||||||
|
|
||||||
LokasiTps::create([
|
LokasiTps::create([
|
||||||
'kategori_tps_id' => $request->kategori_tps_id,
|
'kategori_tps_id' => $request->kategori_tps_id,
|
||||||
|
|
@ -147,11 +138,6 @@ public function store(Request $request)
|
||||||
->with('success', 'Data TPS berhasil ditambahkan.');
|
->with('success', 'Data TPS berhasil ditambahkan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| EDIT
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$title = 'Edit TPS';
|
$title = 'Edit TPS';
|
||||||
|
|
@ -161,16 +147,12 @@ public function edit($id)
|
||||||
return view('admin.tps.edit', compact('title', 'tps', 'kategori'));
|
return view('admin.tps.edit', compact('title', 'tps', 'kategori'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| UPDATE
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$tps = LokasiTps::findOrFail($id);
|
$tps = LokasiTps::findOrFail($id);
|
||||||
|
|
||||||
$request->validate(
|
$validator = Validator::make(
|
||||||
|
$request->all(),
|
||||||
[
|
[
|
||||||
'kategori_tps_id' => 'required|exists:kategori_tps,id_kategori_tps',
|
'kategori_tps_id' => 'required|exists:kategori_tps,id_kategori_tps',
|
||||||
'nama_tps' => 'required|string|max:255',
|
'nama_tps' => 'required|string|max:255',
|
||||||
|
|
@ -183,25 +165,31 @@ public function update(Request $request, $id)
|
||||||
'foto_tps' => 'nullable|image|mimes:jpg,jpeg,png|max:4096',
|
'foto_tps' => 'nullable|image|mimes:jpg,jpeg,png|max:4096',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'kategori_tps_id.required' => 'Kategori TPS wajib dipilih.',
|
||||||
|
'nama_tps.required' => 'Nama TPS wajib diisi.',
|
||||||
|
'alamat_tps.required' => 'Alamat TPS wajib diisi.',
|
||||||
'tahun_pembuatan.digits' => 'Tahun pembuatan harus 4 digit.',
|
'tahun_pembuatan.digits' => 'Tahun pembuatan harus 4 digit.',
|
||||||
|
'kapasitas_tps.min' => 'Kapasitas TPS minimal 1.',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return back()->withErrors($validator)->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
$latitude = $this->convertToDecimal($request->latitude);
|
$latitude = $this->convertToDecimal($request->latitude);
|
||||||
$longitude = $this->convertToDecimal($request->longitude);
|
$longitude = $this->convertToDecimal($request->longitude);
|
||||||
|
|
||||||
$errors = [];
|
|
||||||
|
|
||||||
if ($latitude === null || $latitude < -90 || $latitude > 90) {
|
if ($latitude === null || $latitude < -90 || $latitude > 90) {
|
||||||
$errors['latitude'] = 'Latitude tidak valid.';
|
$validator->errors()->add('latitude', 'Latitude tidak valid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($longitude === null || $longitude < -180 || $longitude > 180) {
|
if ($longitude === null || $longitude < -180 || $longitude > 180) {
|
||||||
$errors['longitude'] = 'Longitude tidak valid.';
|
$validator->errors()->add('longitude', 'Longitude tidak valid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($errors)) {
|
if ($validator->fails()) {
|
||||||
return back()->withErrors($errors)->withInput();
|
return back()->withErrors($validator)->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->hasFile('foto_tps')) {
|
if ($request->hasFile('foto_tps')) {
|
||||||
|
|
@ -229,11 +217,6 @@ public function update(Request $request, $id)
|
||||||
->with('success', 'Data TPS berhasil diperbarui.');
|
->with('success', 'Data TPS berhasil diperbarui.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| DELETE
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$tps = LokasiTps::findOrFail($id);
|
$tps = LokasiTps::findOrFail($id);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('foto')->nullable()->after('role');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('foto');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 860 KiB |
|
|
@ -1,39 +1,72 @@
|
||||||
@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">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<h4 class="card-title">Tambah Kategori TPS</h4>
|
<h4 class="card-title">Tambah Kategori TPS</h4>
|
||||||
<p class="card-description">Form tambah data kategori TPS</p>
|
<p class="card-description">Form tambah data kategori TPS</p>
|
||||||
|
|
||||||
<form action="{{ route('admin.kategori.store') }}" method="POST" enctype="multipart/form-data">
|
<form action="{{ route('admin.kategori.store') }}" method="POST" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
|
{{-- NAMA KATEGORI --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Nama Kategori</label>
|
<label>Nama Kategori</label>
|
||||||
<input type="text" name="nama_kategori" class="form-control" placeholder="Nama Kategori">
|
<input type="text"
|
||||||
|
name="nama_kategori"
|
||||||
|
class="form-control @error('nama_kategori') is-invalid @enderror"
|
||||||
|
placeholder="Nama Kategori"
|
||||||
|
value="{{ old('nama_kategori') }}">
|
||||||
|
|
||||||
|
@error('nama_kategori')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- KEPANJANGAN --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Kepanjangan Kategori</label>
|
<label>Kepanjangan Kategori</label>
|
||||||
<input type="text" name="kepanjangan_kategori" class="form-control" placeholder="Kepanjangan Kategori">
|
<input type="text"
|
||||||
|
name="kepanjangan_kategori"
|
||||||
|
class="form-control @error('kepanjangan_kategori') is-invalid @enderror"
|
||||||
|
placeholder="Kepanjangan Kategori"
|
||||||
|
value="{{ old('kepanjangan_kategori') }}">
|
||||||
|
|
||||||
|
@error('kepanjangan_kategori')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- DESKRIPSI --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="exampleTextarea1">Deskripsi</label>
|
<label>Deskripsi</label>
|
||||||
<textarea name="deskripsi" class="form-control" id="exampleTextarea1" rows="8" placeholder="Deskripsi"></textarea>
|
<textarea name="deskripsi"
|
||||||
|
class="form-control @error('deskripsi') is-invalid @enderror"
|
||||||
|
rows="6"
|
||||||
|
placeholder="Deskripsi">{{ old('deskripsi') }}</textarea>
|
||||||
|
|
||||||
|
@error('deskripsi')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- FOTO --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Foto Kategori</label>
|
<label>Foto Kategori</label>
|
||||||
|
|
||||||
<input type="file" name="foto_kategori" id="foto_kategori" class="file-upload-default">
|
<input type="file"
|
||||||
|
name="foto_kategori"
|
||||||
|
id="foto_kategori"
|
||||||
|
class="file-upload-default @error('foto_kategori') 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
|
<input type="text"
|
||||||
|
class="form-control file-upload-info"
|
||||||
|
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">
|
||||||
|
|
@ -41,10 +74,13 @@
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@error('foto_kategori')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||||
<button class="btn btn-primary">Simpan</button>
|
|
||||||
<a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
|
<a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
@ -52,5 +88,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,78 @@
|
||||||
@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">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<h4 class="card-title">Edit Kategori TPS</h4>
|
<h4 class="card-title">Edit Kategori TPS</h4>
|
||||||
<p class="card-description">Form edit data kategori TPS</p>
|
<p class="card-description">Form edit data kategori TPS</p>
|
||||||
|
|
||||||
<form action="{{ route('admin.kategori.update', $kategori->id_kategori_tps) }}" method="POST"
|
<form action="{{ route('admin.kategori.update', $kategori->id_kategori_tps) }}"
|
||||||
|
method="POST"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
|
|
||||||
|
{{-- NAMA KATEGORI --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Nama Kategori</label>
|
<label>Nama Kategori</label>
|
||||||
<input type="text" name="nama_kategori" value="{{ $kategori->nama_kategori }}"
|
<input type="text"
|
||||||
class="form-control" required>
|
name="nama_kategori"
|
||||||
|
class="form-control @error('nama_kategori') is-invalid @enderror"
|
||||||
|
value="{{ old('nama_kategori', $kategori->nama_kategori) }}"
|
||||||
|
required>
|
||||||
|
|
||||||
|
@error('nama_kategori')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- KEPANJANGAN --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Kepanjangan Kategori</label>
|
<label>Kepanjangan Kategori</label>
|
||||||
<input type="text" name="kepanjangan_kategori" value="{{ $kategori->kepanjangan_kategori }}"
|
<input type="text"
|
||||||
class="form-control">
|
name="kepanjangan_kategori"
|
||||||
|
class="form-control @error('kepanjangan_kategori') is-invalid @enderror"
|
||||||
|
value="{{ old('kepanjangan_kategori', $kategori->kepanjangan_kategori) }}">
|
||||||
|
|
||||||
|
@error('kepanjangan_kategori')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- DESKRIPSI --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Deskripsi</label>
|
<label>Deskripsi</label>
|
||||||
<textarea name="deskripsi" rows="8" class="form-control">{{ $kategori->deskripsi }}</textarea>
|
<textarea name="deskripsi"
|
||||||
|
rows="6"
|
||||||
|
class="form-control @error('deskripsi') is-invalid @enderror"
|
||||||
|
placeholder="Deskripsi">{{ old('deskripsi', $kategori->deskripsi) }}</textarea>
|
||||||
|
|
||||||
|
@error('deskripsi')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- FOTO --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Foto Kategori</label>
|
<label>Foto Kategori</label>
|
||||||
|
|
||||||
<!-- INPUT FILE ASLI (HIDDEN - TEMPLATE) -->
|
<!-- INPUT FILE ASLI -->
|
||||||
<input type="file" name="foto_kategori" id="foto_kategori" class="file-upload-default"
|
<input type="file"
|
||||||
|
name="foto_kategori"
|
||||||
|
id="foto_kategori"
|
||||||
|
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" class="form-control file-upload-info" disabled
|
<input type="text"
|
||||||
|
class="form-control file-upload-info"
|
||||||
|
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
|
||||||
|
|
@ -50,17 +80,21 @@ class="form-control">
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- PREVIEW FOTO LAMA -->
|
@error('foto_kategori')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
|
||||||
|
{{-- PREVIEW FOTO LAMA --}}
|
||||||
@if ($kategori->foto_kategori)
|
@if ($kategori->foto_kategori)
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<img src="{{ asset('storage/' . $kategori->foto_kategori) }}" width="250"
|
<img src="{{ asset('storage/' . $kategori->foto_kategori) }}"
|
||||||
|
width="250"
|
||||||
class="img-thumbnail">
|
class="img-thumbnail">
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||||
<button class="btn btn-primary">Simpan</button>
|
|
||||||
<a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
|
<a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
@ -68,5 +102,5 @@ class="img-thumbnail">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="deskripsi-truncate-div">
|
<div class="text-justify deskripsi-truncate-div">
|
||||||
{{ $item->deskripsi ?? '-' }}
|
{{ $item->deskripsi ?? '-' }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
<img
|
<img
|
||||||
src="{{ $admin->foto
|
src="{{ $admin->foto
|
||||||
? asset('storage/foto-admin/' . $admin->foto)
|
? asset('assets/admin/foto-admin/' . $admin->foto)
|
||||||
: asset('assets/admin/images/user.jpg') }}"
|
: asset('assets/admin/images/user.jpg') }}"
|
||||||
class="mb-3 rounded-circle"
|
class="mb-3 rounded-circle"
|
||||||
width="160"
|
width="160"
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,13 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Tahun</label>
|
<label>Tahun</label>
|
||||||
<input type="number" name="tahun" class="form-control"
|
<input type="number" name="tahun"
|
||||||
placeholder="Contoh: 2024" required>
|
class="form-control @error('tahun') is-invalid @enderror"
|
||||||
|
value="{{ old('tahun') }}"
|
||||||
|
placeholder="Contoh: 2024">
|
||||||
|
@error('tahun')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -25,12 +30,16 @@
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_sampah"
|
<input type="number" step="0.01" name="total_sampah"
|
||||||
id="total_sampah"
|
id="total_sampah"
|
||||||
class="form-control"
|
class="form-control @error('total_sampah') is-invalid @enderror"
|
||||||
placeholder="Total sampah dihasilkan" required>
|
value="{{ old('total_sampah') }}"
|
||||||
|
placeholder="Total sampah dihasilkan">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@error('total_sampah')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -38,12 +47,16 @@ class="form-control"
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_kelola"
|
<input type="number" step="0.01" name="total_kelola"
|
||||||
id="total_kelola"
|
id="total_kelola"
|
||||||
class="form-control"
|
class="form-control @error('total_kelola') is-invalid @enderror"
|
||||||
placeholder="Total sampah yang dikelola" required>
|
value="{{ old('total_kelola') }}"
|
||||||
|
placeholder="Total sampah yang dikelola">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@error('total_kelola')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -51,12 +64,16 @@ class="form-control"
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_daur_ulang"
|
<input type="number" step="0.01" name="total_daur_ulang"
|
||||||
id="total_daur_ulang"
|
id="total_daur_ulang"
|
||||||
class="form-control"
|
class="form-control @error('total_daur_ulang') is-invalid @enderror"
|
||||||
placeholder="Total sampah yang didaur ulang" required>
|
value="{{ old('total_daur_ulang') }}"
|
||||||
|
placeholder="Total sampah yang didaur ulang">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@error('total_daur_ulang')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
||||||
|
|
@ -17,44 +17,57 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Tahun</label>
|
<label>Tahun</label>
|
||||||
<input type="number" name="tahun" class="form-control"
|
<input type="number" name="tahun"
|
||||||
value="{{ old('tahun', $sampah->tahun) }}" required>
|
class="form-control @error('tahun') is-invalid @enderror"
|
||||||
|
value="{{ old('tahun', $sampah->tahun) }}">
|
||||||
|
@error('tahun')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah</label>
|
<label>Total Sampah</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_sampah"
|
<input type="number" step="0.01" name="total_sampah"
|
||||||
class="form-control"
|
class="form-control @error('total_sampah') is-invalid @enderror"
|
||||||
value="{{ old('total_sampah', $sampah->total_sampah) }}" required>
|
value="{{ old('total_sampah', $sampah->total_sampah) }}">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@error('total_sampah')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah Dikelola</label>
|
<label>Total Sampah Dikelola</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_kelola"
|
<input type="number" step="0.01" name="total_kelola"
|
||||||
class="form-control"
|
class="form-control @error('total_kelola') is-invalid @enderror"
|
||||||
value="{{ old('total_kelola', $sampah->total_kelola) }}" required>
|
value="{{ old('total_kelola', $sampah->total_kelola) }}">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@error('total_kelola')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah Daur Ulang</label>
|
<label>Total Sampah Daur Ulang</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_daur_ulang"
|
<input type="number" step="0.01" name="total_daur_ulang"
|
||||||
class="form-control"
|
class="form-control @error('total_daur_ulang') is-invalid @enderror"
|
||||||
value="{{ old('total_daur_ulang', $sampah->total_daur_ulang) }}" required>
|
value="{{ old('total_daur_ulang', $sampah->total_daur_ulang) }}">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@error('total_daur_ulang')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@
|
||||||
<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">
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/cropperjs/dist/cropper.min.css">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Turunkan icon SweetAlert2 */
|
/* Turunkan icon SweetAlert2 */
|
||||||
.swal2-icon {
|
.swal2-icon {
|
||||||
|
|
@ -51,7 +53,15 @@
|
||||||
<ul class="navbar-nav navbar-nav-right">
|
<ul class="navbar-nav navbar-nav-right">
|
||||||
<li class="nav-item nav-profile dropdown">
|
<li class="nav-item nav-profile dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" id="profileDropdown">
|
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" id="profileDropdown">
|
||||||
<img src="{{ asset('assets/admin/images/user.jpg') }}" alt="profile" />
|
@php
|
||||||
|
$user = Auth::user();
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<img src="{{ $user && $user->foto
|
||||||
|
? asset('assets/admin/foto-admin/' . $user->foto)
|
||||||
|
: asset('assets/admin/images/user.jpg') }}"
|
||||||
|
alt="profile" />
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu dropdown-menu-right navbar-dropdown"
|
<div class="dropdown-menu dropdown-menu-right navbar-dropdown"
|
||||||
aria-labelledby="profileDropdown">
|
aria-labelledby="profileDropdown">
|
||||||
|
|
@ -120,6 +130,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="https://unpkg.com/cropperjs/dist/cropper.min.js"></script>
|
||||||
|
|
||||||
<!-- plugins:js -->
|
<!-- plugins:js -->
|
||||||
<script src="{{ asset('assets/admin/vendors/js/vendor.bundle.base.js') }}"></script>
|
<script src="{{ asset('assets/admin/vendors/js/vendor.bundle.base.js') }}"></script>
|
||||||
<!-- endinject -->
|
<!-- endinject -->
|
||||||
|
|
|
||||||
|
|
@ -6,38 +6,46 @@
|
||||||
<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">
|
||||||
|
|
||||||
<h4 class="card-title">Tambah Data TPS</h4>
|
<h4 class="card-title">Tambah Data TPS</h4>
|
||||||
<p class="card-description">Form tambah data TPS</p>
|
<p class="card-description">Form tambah data TPS</p>
|
||||||
|
|
||||||
<form action="{{ route('admin.tps.store') }}" method="POST" enctype="multipart/form-data">
|
<form action="{{ route('admin.tps.store') }}" method="POST" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<!-- 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 @error('nama_tps') is-invalid @enderror"
|
||||||
value="{{ old('nama_tps') }}"
|
value="{{ old('nama_tps') }}"
|
||||||
placeholder="Nama TPS">
|
placeholder="Nama TPS">
|
||||||
|
|
||||||
@error('nama_tps')
|
@error('nama_tps')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ALAMAT -->
|
{{-- ALAMAT --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Alamat</label>
|
<label>Alamat</label>
|
||||||
<input type="text" name="alamat_tps" class="form-control"
|
<input type="text"
|
||||||
|
name="alamat_tps"
|
||||||
|
class="form-control @error('alamat_tps') is-invalid @enderror"
|
||||||
value="{{ old('alamat_tps') }}"
|
value="{{ old('alamat_tps') }}"
|
||||||
placeholder="Alamat TPS">
|
placeholder="Alamat TPS">
|
||||||
|
|
||||||
@error('alamat_tps')
|
@error('alamat_tps')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- KATEGORI -->
|
{{-- KATEGORI --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Kategori TPS</label>
|
<label>Kategori TPS</label>
|
||||||
<select name="kategori_tps_id" class="form-control">
|
<select name="kategori_tps_id"
|
||||||
|
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 }}"
|
||||||
|
|
@ -46,76 +54,97 @@
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@error('kategori_tps_id')
|
@error('kategori_tps_id')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- TAHUN -->
|
{{-- TAHUN --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Tahun Pembuatan</label>
|
<label>Tahun Pembuatan</label>
|
||||||
<input type="number" name="tahun_pembuatan" class="form-control"
|
<input type="number"
|
||||||
|
name="tahun_pembuatan"
|
||||||
|
class="form-control @error('tahun_pembuatan') is-invalid @enderror"
|
||||||
value="{{ old('tahun_pembuatan') }}"
|
value="{{ old('tahun_pembuatan') }}"
|
||||||
placeholder="Contoh: 2022">
|
placeholder="Contoh: 2022">
|
||||||
|
|
||||||
@error('tahun_pembuatan')
|
@error('tahun_pembuatan')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 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 @error('kapasitas_tps') is-invalid @enderror"
|
||||||
value="{{ old('kapasitas_tps') }}"
|
value="{{ old('kapasitas_tps') }}"
|
||||||
placeholder="Kapasitas TPS">
|
placeholder="Kapasitas TPS">
|
||||||
|
|
||||||
@error('kapasitas_tps')
|
@error('kapasitas_tps')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- STATUS -->
|
{{-- STATUS --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Status</label>
|
<label>Status</label>
|
||||||
<select name="status_tps" class="form-control">
|
<select name="status_tps"
|
||||||
|
class="form-control @error('status_tps') is-invalid @enderror">
|
||||||
|
<option value="">Pilih Status</option>
|
||||||
<option value="Aktif" {{ old('status_tps') == 'Aktif' ? 'selected' : '' }}>Aktif</option>
|
<option value="Aktif" {{ old('status_tps') == 'Aktif' ? 'selected' : '' }}>Aktif</option>
|
||||||
<option value="Tidak Aktif" {{ old('status_tps') == 'Tidak Aktif' ? 'selected' : '' }}>Tidak Aktif</option>
|
<option value="Tidak Aktif" {{ old('status_tps') == 'Tidak Aktif' ? 'selected' : '' }}>Tidak Aktif</option>
|
||||||
<option value="Pembangunan" {{ old('status_tps') == 'Pembangunan' ? 'selected' : '' }}>Pembangunan</option>
|
<option value="Pembangunan" {{ old('status_tps') == 'Pembangunan' ? 'selected' : '' }}>Pembangunan</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@error('status_tps')
|
@error('status_tps')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 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 @error('latitude') is-invalid @enderror"
|
||||||
value="{{ old('latitude') }}"
|
value="{{ old('latitude') }}"
|
||||||
placeholder="Contoh: -7.623 atau 7°35'17.25"S">
|
placeholder="Contoh: -7.623 atau 7°35'17.25"S">
|
||||||
|
|
||||||
@error('latitude')
|
@error('latitude')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</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 @error('longitude') is-invalid @enderror"
|
||||||
value="{{ old('longitude') }}"
|
value="{{ old('longitude') }}"
|
||||||
placeholder="Contoh: 111.980 atau 111°55'0.97"E">
|
placeholder="Contoh: 111.980 atau 111°55'0.97"E">
|
||||||
|
|
||||||
@error('longitude')
|
@error('longitude')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</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" id="foto_tps" class="file-upload-default">
|
<input type="file"
|
||||||
|
name="foto_tps"
|
||||||
|
id="foto_tps"
|
||||||
|
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
|
<input type="text"
|
||||||
|
class="form-control file-upload-info"
|
||||||
|
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">
|
||||||
|
|
@ -129,7 +158,7 @@
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="mr-2 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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ function decimalToDms($decimal, $type = 'lat')
|
||||||
}
|
}
|
||||||
|
|
||||||
$direction = $decimal >= 0 ? ($type === 'lat' ? 'N' : 'E') : ($type === 'lat' ? 'S' : 'W');
|
$direction = $decimal >= 0 ? ($type === 'lat' ? 'N' : 'E') : ($type === 'lat' ? 'S' : 'W');
|
||||||
|
|
||||||
$decimal = abs($decimal);
|
$decimal = abs($decimal);
|
||||||
|
|
||||||
$degree = floor($decimal);
|
$degree = floor($decimal);
|
||||||
|
|
@ -21,131 +20,148 @@ function decimalToDms($decimal, $type = 'lat')
|
||||||
@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">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">Edit Data TPS</h4>
|
|
||||||
<p class="card-description">
|
|
||||||
Form edit data Tempat Pembuangan Sampah
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<form action="{{ route('admin.tps.update', $tps->id_tps) }}" method="POST"
|
<h4 class="card-title">Edit Data TPS</h4>
|
||||||
enctype="multipart/form-data" class="forms-sample">
|
<p class="card-description">Form edit data Tempat Pembuangan Sampah</p>
|
||||||
|
|
||||||
|
<form action="{{ route('admin.tps.update', $tps->id_tps) }}"
|
||||||
|
method="POST"
|
||||||
|
enctype="multipart/form-data"
|
||||||
|
class="forms-sample">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
|
|
||||||
{{-- 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"
|
||||||
value="{{ old('nama_tps') ?? $tps->nama_tps }}" required>
|
name="nama_tps"
|
||||||
|
class="form-control @error('nama_tps') is-invalid @enderror"
|
||||||
|
value="{{ old('nama_tps', $tps->nama_tps) }}">
|
||||||
|
|
||||||
@error('nama_tps')
|
@error('nama_tps')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Alamat --}}
|
{{-- ALAMAT --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Alamat</label>
|
<label>Alamat</label>
|
||||||
<input type="text" name="alamat_tps" class="form-control"
|
<input type="text"
|
||||||
value="{{ old('alamat_tps') ?? $tps->alamat_tps }}" required>
|
name="alamat_tps"
|
||||||
|
class="form-control @error('alamat_tps') is-invalid @enderror"
|
||||||
|
value="{{ old('alamat_tps', $tps->alamat_tps) }}">
|
||||||
|
|
||||||
@error('alamat_tps')
|
@error('alamat_tps')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Kategori TPS --}}
|
{{-- KATEGORI --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<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 @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')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Tahun Pembuatan --}}
|
{{-- TAHUN --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Tahun Pembuatan</label>
|
<label>Tahun Pembuatan</label>
|
||||||
<input type="number" name="tahun_pembuatan" class="form-control"
|
<input type="number"
|
||||||
value="{{ old('tahun_pembuatan') ?? $tps->tahun_pembuatan }}" required>
|
name="tahun_pembuatan"
|
||||||
|
class="form-control @error('tahun_pembuatan') is-invalid @enderror"
|
||||||
|
value="{{ old('tahun_pembuatan', $tps->tahun_pembuatan) }}">
|
||||||
|
|
||||||
@error('tahun_pembuatan')
|
@error('tahun_pembuatan')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Kapasitas TPS --}}
|
{{-- KAPASITAS --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Kapasitas TPS</label>
|
<label>Kapasitas TPS</label>
|
||||||
<input type="number" name="kapasitas_tps" class="form-control"
|
<input type="number"
|
||||||
value="{{ old('kapasitas_tps') ?? $tps->kapasitas_tps }}" required>
|
name="kapasitas_tps"
|
||||||
|
class="form-control @error('kapasitas_tps') is-invalid @enderror"
|
||||||
|
value="{{ old('kapasitas_tps', $tps->kapasitas_tps) }}">
|
||||||
|
|
||||||
@error('kapasitas_tps')
|
@error('kapasitas_tps')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Status TPS --}}
|
{{-- STATUS --}}
|
||||||
<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"
|
||||||
<option value="Aktif"
|
class="form-control @error('status_tps') is-invalid @enderror">
|
||||||
{{ (old('status_tps') ?? $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>Aktif
|
<option value="Aktif" {{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>Aktif</option>
|
||||||
</option>
|
<option value="Tidak Aktif" {{ old('status_tps', $tps->status_tps) == 'Tidak Aktif' ? 'selected' : '' }}>Tidak Aktif</option>
|
||||||
<option value="Tidak Aktif"
|
<option value="Pembangunan" {{ old('status_tps', $tps->status_tps) == 'Pembangunan' ? 'selected' : '' }}>Pembangunan</option>
|
||||||
{{ (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')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Latitude --}}
|
{{-- LATITUDE --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Latitude</label>
|
<label>Latitude</label>
|
||||||
<input type="text" name="latitude" class="form-control" placeholder="Contoh: 7°35'17.25S"
|
<input type="text"
|
||||||
value="{{ old('latitude') ?? decimalToDms($tps->latitude, 'lat') }}" required>
|
name="latitude"
|
||||||
|
class="form-control @error('latitude') is-invalid @enderror"
|
||||||
|
value="{{ old('latitude', decimalToDms($tps->latitude, 'lat')) }}"
|
||||||
|
placeholder="Contoh: 7°35'17.25S">
|
||||||
|
|
||||||
@error('latitude')
|
@error('latitude')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</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"
|
||||||
placeholder="Contoh: 111°55'0.97E"
|
name="longitude"
|
||||||
value="{{ old('longitude') ?? decimalToDms($tps->longitude, 'lng') }}" required>
|
class="form-control @error('longitude') is-invalid @enderror"
|
||||||
|
value="{{ old('longitude', decimalToDms($tps->longitude, 'lng')) }}"
|
||||||
|
placeholder="Contoh: 111°55'0.97E">
|
||||||
|
|
||||||
@error('longitude')
|
@error('longitude')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Foto TPS --}}
|
{{-- FOTO --}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Foto TPS</label>
|
<label>Foto TPS</label>
|
||||||
|
|
||||||
<input type="file" name="foto_tps" id="foto_tps" class="file-upload-default">
|
<input type="file"
|
||||||
|
name="foto_tps"
|
||||||
|
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
|
<input type="text" 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" type="button">
|
<button class="file-upload-browse btn btn-primary" type="button">Upload</button>
|
||||||
Upload
|
|
||||||
</button>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -155,38 +171,20 @@ function decimalToDms($decimal, $type = 'lat')
|
||||||
|
|
||||||
@if ($tps->foto_tps)
|
@if ($tps->foto_tps)
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<img src="{{ asset('storage/' . $tps->foto_tps) }}" width="250"
|
<img src="{{ asset('storage/' . $tps->foto_tps) }}"
|
||||||
|
width="250"
|
||||||
class="img-thumbnail">
|
class="img-thumbnail">
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Button --}}
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||||
<button type="submit" class="mr-2 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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
document.querySelectorAll('.file-upload-browse').forEach(function(button) {
|
|
||||||
button.addEventListener('click', function() {
|
|
||||||
this.closest('.form-group')
|
|
||||||
.querySelector('.file-upload-default')
|
|
||||||
.click();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelectorAll('.file-upload-default').forEach(function(input) {
|
</div>
|
||||||
input.addEventListener('change', function() {
|
</div>
|
||||||
const fileName = this.files[0]?.name || '';
|
</div>
|
||||||
this.closest('.form-group')
|
</div>
|
||||||
.querySelector('.file-upload-info')
|
</div>
|
||||||
.value = fileName;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue