diff --git a/app/Http/Controllers/MasterData/LandController.php b/app/Http/Controllers/MasterData/LandController.php
new file mode 100644
index 0000000..d5af241
--- /dev/null
+++ b/app/Http/Controllers/MasterData/LandController.php
@@ -0,0 +1,102 @@
+get();
+ return view('master-data.lahan.index', compact('lands'));
+ }
+
+ public function store(Request $request)
+ {
+ $customMessage = [
+ 'name.required' => 'Nama wajib diisi',
+ 'name.max' => 'Nama maksimal 255 karakter',
+ 'name.string' => 'Nama harus berupa string',
+
+ 'description.required' => 'Deskripsi wajib diisi',
+ 'description.max' => 'Deskripsi maksimal 255 karakter',
+ 'description.string' => 'Deskripsi harus berupa string',
+ ];
+
+ $validator = Validator::make($request->all(), [
+ 'land_name' => 'required|string|max:255',
+ 'description' => 'required|string|max:255',
+ ], $customMessage);
+
+ if ($validator->fails()) {
+ toast($validator->messages()->all()[0], 'error')->position('top')->autoclose(3000);
+ return redirect()->back()->withInput();
+ }
+
+ $land = new Land();
+ $land->name = $request->land_name;
+ $land->description = $request->description;
+
+ try {
+ $land->save();
+ toast('Data berhasil disimpan', 'success')->position('top-right')->autoclose(3000);
+ return redirect()->back();
+ } catch (\Throwable $th) {
+ toast('Terjadi kesalahan', 'error')->position('top')->autoclose(3000);
+ return redirect()->back();
+ }
+ }
+
+ public function update(Request $request, $id)
+ {
+ $customMessage = [
+ 'name.required' => 'Nama wajib diisi',
+ 'name.max' => 'Nama maksimal 255 karakter',
+ 'name.string' => 'Nama harus berupa string',
+
+ 'description.required' => 'Deskripsi wajib diisi',
+ 'description.max' => 'Deskripsi maksimal 255 karakter',
+ 'description.string' => 'Deskripsi harus berupa string',
+ ];
+
+ $validator = Validator::make($request->all(), [
+ 'land_name' => 'required|string|max:255',
+ 'description' => 'required|string|max:255',
+ ], $customMessage);
+
+ if ($validator->fails()) {
+ toast($validator->messages()->all()[0], 'error')->position('top')->autoclose(3000);
+ return redirect()->back()->withInput();
+ }
+
+ $land = Land::find($id);
+ $land->name = $request->land_name;
+ $land->description = $request->description;
+
+ try {
+ $land->save();
+ toast('Data berhasil diubah', 'success')->position('top-right')->autoclose(3000);
+ return redirect()->back();
+ } catch (\Throwable $th) {
+ toast('Terjadi kesalahan', 'error')->position('top')->autoclose(3000);
+ return redirect()->back();
+ }
+ }
+
+ public function destroy($id)
+ {
+ $land = Land::find($id);
+ try {
+ $land->delete();
+ toast('Data berhasil dihapus', 'success')->position('top-right')->autoclose(3000);
+ return redirect()->back();
+ } catch (\Throwable $th) {
+ toast('Terjadi kesalahan', 'error')->position('top')->autoclose(3000);
+ return redirect()->back();
+ }
+ }
+}
diff --git a/app/Models/Land.php b/app/Models/Land.php
new file mode 100644
index 0000000..558005f
--- /dev/null
+++ b/app/Models/Land.php
@@ -0,0 +1,18 @@
+id();
+ $table->string('name');
+ $table->text('description');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('land');
+ }
+};
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index 7759455..c21e090 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -20,7 +20,8 @@ public function run(): void
// ]);
$this->call([
- UsersSeeder::class
+ UsersSeeder::class,
+ LandSeeder::class
]);
}
}
diff --git a/database/seeders/LandSeeder.php b/database/seeders/LandSeeder.php
new file mode 100644
index 0000000..12d5d38
--- /dev/null
+++ b/database/seeders/LandSeeder.php
@@ -0,0 +1,27 @@
+ 'Land 1',
+ 'description' => 'Land 1 Description',
+ ]),
+ Land::create([
+ 'name' => 'Land 2',
+ 'description' => 'Land 2 Description',
+ ])
+ ];
+ }
+}
diff --git a/public/assets/js/pages/customJs/master-data/lahan/index.js b/public/assets/js/pages/customJs/master-data/lahan/index.js
new file mode 100644
index 0000000..199689b
--- /dev/null
+++ b/public/assets/js/pages/customJs/master-data/lahan/index.js
@@ -0,0 +1,248 @@
+function updateData(land) {
+ var form = document.getElementById("edit-form");
+ var landName = document.getElementById("landname-edit-field");
+ var status = document.getElementById("status-edit-field");
+
+ landName.value = land.name;
+ status.value = land.description;
+ form.action = "/data-lahan/" + land.id;
+}
+
+function deleteData(id) {
+ var form = document.getElementById("delete-form");
+ form.action = "/data-lahan/" + id;
+}
+
+var perPage = 10,
+ options = {
+ valueNames: ["id", "land_name", "status"],
+ page: perPage,
+ pagination: !0,
+ plugins: [ListPagination({ left: 2, right: 2 })],
+ },
+ customerList = new List("customerList", options).on(
+ "updated",
+ function (e) {
+ 0 == e.matchingItems.length
+ ? (document.getElementsByClassName(
+ "noresult"
+ )[0].style.display = "block")
+ : (document.getElementsByClassName(
+ "noresult"
+ )[0].style.display = "none");
+ var t = 1 == e.i,
+ a = e.i > e.matchingItems.length - e.page;
+ document.querySelector(".pagination-prev.disabled") &&
+ document
+ .querySelector(".pagination-prev.disabled")
+ .classList.remove("disabled"),
+ document.querySelector(".pagination-next.disabled") &&
+ document
+ .querySelector(".pagination-next.disabled")
+ .classList.remove("disabled"),
+ t &&
+ document
+ .querySelector(".pagination-prev")
+ .classList.add("disabled"),
+ a &&
+ document
+ .querySelector(".pagination-next")
+ .classList.add("disabled"),
+ e.matchingItems.length <= perPage
+ ? (document.querySelector(
+ ".pagination-wrap"
+ ).style.display = "none")
+ : (document.querySelector(
+ ".pagination-wrap"
+ ).style.display = "flex"),
+ e.matchingItems.length == perPage &&
+ document
+ .querySelector(".pagination.listjs-pagination")
+ .firstElementChild.children[0].click(),
+ 0 < e.matchingItems.length
+ ? (document.getElementsByClassName(
+ "noresult"
+ )[0].style.display = "none")
+ : (document.getElementsByClassName(
+ "noresult"
+ )[0].style.display = "block");
+ }
+ );
+isCount = new DOMParser().parseFromString(
+ customerList.items.slice(-1)[0]._values.id,
+ "text/html"
+);
+var isValue = isCount.body.firstElementChild.innerHTML,
+ idField = document.getElementById("id-field"),
+ customerNameField = document.getElementById("customername-field"),
+ emailField = document.getElementById("email-field"),
+ dateField = document.getElementById("date-field"),
+ phoneField = document.getElementById("phone-field"),
+ statusField = document.getElementById("status-field"),
+ addBtn = document.getElementById("add-btn"),
+ editBtn = document.getElementById("edit-btn"),
+ removeBtns = document.getElementsByClassName("remove-item-btn"),
+ editBtns = document.getElementsByClassName("edit-item-btn");
+function filterContact(e) {
+ var t = e;
+ customerList.filter(function (e) {
+ matchData = new DOMParser().parseFromString(
+ e.values().status,
+ "text/html"
+ );
+ e = matchData.body.firstElementChild.innerHTML;
+ return "All" == e || "All" == t || e == t;
+ }),
+ customerList.update();
+}
+function updateList() {
+ var a = document.querySelector("input[name=status]:checked").value;
+ (data = userList.filter(function (e) {
+ var t = !1;
+ return (
+ "All" == a
+ ? (t = !0)
+ : ((t = e.values().sts == a), console.log(t, "statusFilter")),
+ t
+ );
+ })),
+ userList.update();
+}
+refreshCallbacks(),
+ filterContact("All"),
+ document
+ .getElementById("showModal")
+ .addEventListener("show.bs.modal", function (e) {
+ e.relatedTarget.classList.contains("edit-item-btn")
+ ? ((document.getElementById("exampleModalLabel").innerHTML =
+ "Edit Customer"),
+ (document
+ .getElementById("showModal")
+ .querySelector(".modal-footer").style.display = "block"),
+ (document.getElementById("add-btn").style.display = "none"),
+ (document.getElementById("edit-btn").style.display = "block"))
+ : e.relatedTarget.classList.contains("add-btn")
+ ? ((document.getElementById("exampleModalLabel").innerHTML =
+ "Tambah Data Lahan"),
+ (document
+ .getElementById("showModal")
+ .querySelector(".modal-footer").style.display = "block"),
+ (document.getElementById("edit-btn").style.display = "none"),
+ (document.getElementById("add-btn").style.display = "block"))
+ : ((document.getElementById("exampleModalLabel").innerHTML =
+ "List Customer"),
+ (document
+ .getElementById("showModal")
+ .querySelector(".modal-footer").style.display = "none"));
+ }),
+ ischeckboxcheck(),
+ document
+ .getElementById("showModal")
+ .addEventListener("hidden.bs.modal", function () {
+ clearFields();
+ }),
+ document
+ .querySelector("#customerList")
+ .addEventListener("click", function () {
+ refreshCallbacks(), ischeckboxcheck();
+ });
+var table = document.getElementById("customerTable"),
+ tr = table.getElementsByTagName("tr"),
+ trlist = table.querySelectorAll(".list tr"),
+ count = Number(isValue.replace(/[^0-9]/g, "")) + 1;
+addBtn.addEventListener("click", function (e) {
+ "" !== customerNameField.value &&
+ "" !== emailField.value &&
+ "" !== dateField.value &&
+ "" !== phoneField.value &&
+ (customerList.add({
+ id:
+ '#VZ' +
+ count +
+ "",
+ customer_name: customerNameField.value,
+ email: emailField.value,
+ date: dateField.value,
+ phone: phoneField.value,
+ status: isStatus(statusField.value),
+ }),
+ document.getElementById("close-modal").click(),
+ clearFields(),
+ refreshCallbacks(),
+ filterContact("All"),
+ count++);
+}),
+ // var statusVal = new Choices(statusField);
+ function isStatus(e) {
+ switch (e) {
+ case "Active":
+ return (
+ '' +
+ e +
+ ""
+ );
+ case "Block":
+ return (
+ '' +
+ e +
+ ""
+ );
+ }
+ };
+function ischeckboxcheck() {
+ document.getElementsByName("checkAll").forEach(function (e) {
+ e.addEventListener("click", function (e) {
+ e.target.checked
+ ? e.target.closest("tr").classList.add("table-active")
+ : e.target.closest("tr").classList.remove("table-active");
+ });
+ });
+}
+function refreshCallbacks() {
+ removeBtns.forEach(function (e) {
+ e.addEventListener("click", function (e) {
+ e.target.closest("tr").children[1].innerText,
+ (itemId = e.target.closest("tr").children[1].innerText),
+ customerList.get({ id: itemId }).forEach(function (e) {
+ deleteid = new DOMParser().parseFromString(
+ e._values.id,
+ "text/html"
+ );
+ var t = deleteid.body.firstElementChild;
+ deleteid.body.firstElementChild.innerHTML == itemId &&
+ document
+ .getElementById("delete-record")
+ .addEventListener("click", function () {
+ customerList.remove("id", t.outerHTML),
+ document
+ .getElementById("deleteRecordModal")
+ .click();
+ });
+ });
+ });
+ });
+}
+document
+ .querySelector(".pagination-next")
+ .addEventListener("click", function () {
+ !document.querySelector(".pagination.listjs-pagination") ||
+ (document
+ .querySelector(".pagination.listjs-pagination")
+ .querySelector(".active") &&
+ document
+ .querySelector(".pagination.listjs-pagination")
+ .querySelector(".active")
+ .nextElementSibling.children[0].click());
+ }),
+ document
+ .querySelector(".pagination-prev")
+ .addEventListener("click", function () {
+ !document.querySelector(".pagination.listjs-pagination") ||
+ (document
+ .querySelector(".pagination.listjs-pagination")
+ .querySelector(".active") &&
+ document
+ .querySelector(".pagination.listjs-pagination")
+ .querySelector(".active")
+ .previousSibling.children[0].click());
+ });
diff --git a/resources/views/master-data/lahan/index.blade.php b/resources/views/master-data/lahan/index.blade.php
new file mode 100644
index 0000000..260f6dd
--- /dev/null
+++ b/resources/views/master-data/lahan/index.blade.php
@@ -0,0 +1,264 @@
+@extends('layouts.app')
+@push('title', 'Data Tanah')
+@section('content')
+
+
+
+
+
+
+
+
Data Lahan
+
+
+
+ - Master Data
+ - Data Lahan
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No
+ |
+ Nama Lahan |
+ Deskripsi |
+ Action |
+
+
+
+ @foreach ($lands as $land)
+
+ {{ $loop->iteration }} |
+ #VZ2101 |
+ {{ $land->name }} |
+ {{ $land->description }} |
+
+
+ |
+
+ @endforeach
+
+
+
+
+
+
+
Maaf! Data Tidak Ditemukan
+
Silahkan gunakan kata kunci lain
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{-- add modal --}}
+
+
+ {{-- edit modal --}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Anda yakin ?
+
Anda yakin akan menghapus data ini ?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @push('other-js')
+
+
+
+
+
+
+
+
+
+ @endpush
+@endsection
diff --git a/resources/views/partials/sidebar.blade.php b/resources/views/partials/sidebar.blade.php
index 11620c3..0bf36db 100644
--- a/resources/views/partials/sidebar.blade.php
+++ b/resources/views/partials/sidebar.blade.php
@@ -58,215 +58,11 @@ class="nav-link {{ request()->routeIs('master_data.pengguna.*') ? 'active' : ''
- Chat
-
-
- Mailbox
+ Lahan
-
- Ecommerce
-
-
-
-
-
- Projects
-
-
-
-
- Tasks
-
-
-
-
- CRM
-
-
-
-
- Crypto
-
-
-
-
-
- Invoices
-
-
-
-
-
- Support Tickets
-
-
-
diff --git a/routes/web.php b/routes/web.php
index cee0274..ffbaf74 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -5,7 +5,9 @@
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\Auth\TwoStepVerifyController;
use App\Http\Controllers\DashboardController;
+use App\Http\Controllers\MasterData\LandController;
use App\Http\Controllers\MasterData\UserController;
+use Illuminate\Routing\RouteGroup;
use Illuminate\Support\Facades\Route;
/*
@@ -64,7 +66,13 @@
Route::post('/', 'store')->name('store');
Route::put('/{id}', 'update')->name('update');
Route::delete('/{id}', 'destroy')->name('destroy');
- Route::post('/{id}/send-code', 'sendCode')->name('send_code');
+ });
+
+ Route::prefix('data-lahan')->controller(LandController::class)->name('lahan.')->group(function () {
+ Route::get('/', 'index')->name('index');
+ Route::post('/', 'store')->name('store');
+ Route::put('/{id}', 'update')->name('update');
+ Route::delete('/{id}', 'destroy')->name('destroy');
});
});
});