Merge pull request #14 from arieeefajar/fix/master-land

Fix/master land
This commit is contained in:
Arie Fajar Bachtiar 2025-02-17 20:26:34 +07:00 committed by GitHub
commit 89bc1a102e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 11500 additions and 62 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers;
use App\Models\District;
use App\Models\Province;
use App\Models\Regency;
use Dflydev\DotAccessData\Data;
use Illuminate\Http\Request;
class LocationController extends Controller
{
public function getProvinces()
{
$provinces = Province::all();
return response()->json(['success' => true, 'data' => $provinces]);
}
public function getRegencies($provinceId)
{
$regencies = Regency::where('province_id', $provinceId)->get();
return response()->json(['success' => true, 'data' => $regencies]);
}
public function getDistricts($regencyId)
{
$distircts = District::where('regency_id', $regencyId)->get();
return response()->json(['success' => true, 'data' => $distircts]);
}
}

View File

@ -4,6 +4,7 @@
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Land; use App\Models\Land;
use App\Models\Province;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
@ -12,24 +13,69 @@ class LandController extends Controller
public function index() public function index()
{ {
$lands = Land::orderBy('created_at', 'desc')->get(); $lands = Land::orderBy('created_at', 'desc')->get();
return view('master-data.lahan.index', compact('lands')); $provinces = Province::all();
return view('master-data.lahan.index', compact('lands', 'provinces'));
} }
public function store(Request $request) public function store(Request $request)
{ {
$customMessage = [ $customMessage = [
'name.required' => 'Nama wajib diisi', 'owner.required' => 'Nama pemilik wajib diisi',
'name.max' => 'Nama maksimal 255 karakter', 'owner.max' => 'Nama pemilik maksimal 25 karakter',
'name.string' => 'Nama harus berupa string', 'owner.string' => 'Nama pemilik harus berupa string',
'description.required' => 'Deskripsi wajib diisi', 'nohp.required' => 'Nomor HP wajib diisi',
'description.max' => 'Deskripsi maksimal 255 karakter', 'nohp.min' => 'Nomor HP minimal 10 karakter',
'description.string' => 'Deskripsi harus berupa string', 'nohp.max' => 'Nomor HP maksimal 13 karakter',
'nohp.string' => 'Nomor HP harus berupa string',
'rental_price.required' => 'Harga sewa wajib diisi',
'rental_price.numeric' => 'Harga sewa harus berupa angka',
'rental_start.required' => 'Tanggal mulai sewa wajib diisi',
'rental_start.date' => 'Tanggal mulai sewa harus berupa tanggal',
'rental_start.after_or_equal' => 'Tanggal mulai sewa harus hari ini atau setelahnya',
'rental_until.required' => 'Tanggal sampai sewa wajib diisi',
'rental_until.date' => 'Tanggal sampai sewa harus berupa tanggal',
'rental_until.after_or_equal' => 'Tanggal sampai sewa harus sama atau lebih besar dari tanggal mulai sewa',
'land_name.required' => 'Nama lahan wajib diisi',
'land_name.max' => 'Nama lahan maksimal 25 karakter',
'land_name.string' => 'Nama lahan harus berupa string',
'province_id.required' => 'Provinsi wajib diisi',
'province_id.exists' => 'Provinsi tidak ditemukan',
'regency_id.required' => 'Kota wajib diisi',
'regency_id.exists' => 'Kota tidak ditemukan',
'district_id.required' => 'Kecamatan wajib diisi',
'district_id.exists' => 'Kecamatan tidak ditemukan',
'lat.required' => 'Latitude wajib diisi',
'lat.numeric' => 'Latitude harus berupa angka',
'lng.required' => 'Longitude wajib diisi',
'lng.numeric' => 'Longitude harus berupa angka',
]; ];
$request->merge([
'rental_price' => str_replace('.', '', $request->rental_price),
]);
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'land_name' => 'required|string|max:255', 'owner' => 'required|string|max:25',
'description' => 'required|string|max:255', 'nohp' => 'required|string|min:10|max:13',
'rental_price' => 'required|numeric',
'rental_start' => 'required|date|after_or_equal:today',
'rental_until' => 'required|date|after_or_equal:rental_start',
'land_name' => 'required|string|max:25',
'province_id' => 'required|exists:provinces,id',
'regency_id' => 'required|exists:regencies,id',
'district_id' => 'required|exists:districts,id',
'lat' => 'required|numeric',
'lng' => 'required|numeric',
], $customMessage); ], $customMessage);
if ($validator->fails()) { if ($validator->fails()) {
@ -38,14 +84,24 @@ public function store(Request $request)
} }
$land = new Land(); $land = new Land();
$land->name = $request->land_name; $land->owner = $request->owner;
$land->description = $request->description; $land->no_hp = $request->nohp;
$land->rental_price = $request->rental_price;
$land->rental_start = $request->rental_start;
$land->rental_until = $request->rental_until;
$land->land_name = $request->land_name;
$land->province_code = $request->province_id;
$land->regency_code = $request->regency_id;
$land->district_code = $request->district_id;
$land->latitude = $request->lat;
$land->longitude = $request->lng;
try { try {
$land->save(); $land->save();
toast('Data berhasil disimpan', 'success')->position('top-right')->autoclose(3000); toast('Data berhasil disimpan', 'success')->position('top-right')->autoclose(3000);
return redirect()->back(); return redirect()->back();
} catch (\Throwable $th) { } catch (\Throwable $th) {
dd($th->getMessage());
toast('Terjadi kesalahan', 'error')->position('top')->autoclose(3000); toast('Terjadi kesalahan', 'error')->position('top')->autoclose(3000);
return redirect()->back(); return redirect()->back();
} }
@ -54,18 +110,62 @@ public function store(Request $request)
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
$customMessage = [ $customMessage = [
'name.required' => 'Nama wajib diisi', 'owner.required' => 'Nama pemilik wajib diisi',
'name.max' => 'Nama maksimal 255 karakter', 'owner.max' => 'Nama pemilik maksimal 25 karakter',
'name.string' => 'Nama harus berupa string', 'owner.string' => 'Nama pemilik harus berupa string',
'description.required' => 'Deskripsi wajib diisi', 'nohp.required' => 'Nomor HP wajib diisi',
'description.max' => 'Deskripsi maksimal 255 karakter', 'nohp.min' => 'Nomor HP minimal 10 karakter',
'description.string' => 'Deskripsi harus berupa string', 'nohp.max' => 'Nomor HP maksimal 13 karakter',
'nohp.string' => 'Nomor HP harus berupa string',
'rental_price.required' => 'Harga sewa wajib diisi',
'rental_price.numeric' => 'Harga sewa harus berupa angka',
'rental_start.required' => 'Tanggal mulai sewa wajib diisi',
'rental_start.date' => 'Tanggal mulai sewa harus berupa tanggal',
'rental_start.after_or_equal' => 'Tanggal mulai sewa harus hari ini atau setelahnya',
'rental_until.required' => 'Tanggal sampai sewa wajib diisi',
'rental_until.date' => 'Tanggal sampai sewa harus berupa tanggal',
'rental_until.after_or_equal' => 'Tanggal sampai sewa harus sama atau lebih besar dari tanggal mulai sewa',
'land_name.required' => 'Nama lahan wajib diisi',
'land_name.max' => 'Nama lahan maksimal 25 karakter',
'land_name.string' => 'Nama lahan harus berupa string',
'province_id.required' => 'Provinsi wajib diisi',
'province_id.exists' => 'Provinsi tidak ditemukan',
'regency_id.required' => 'Kota wajib diisi',
'regency_id.exists' => 'Kota tidak ditemukan',
'district_id.required' => 'Kecamatan wajib diisi',
'district_id.exists' => 'Kecamatan tidak ditemukan',
'lat.required' => 'Latitude wajib diisi',
'lat.numeric' => 'Latitude harus berupa angka',
'lng.required' => 'Longitude wajib diisi',
'lng.numeric' => 'Longitude harus berupa angka',
]; ];
$request->merge([
'rental_price' => str_replace('.', '', $request->rental_price),
]);
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'land_name' => 'required|string|max:255', 'owner' => 'required|string|max:25',
'description' => 'required|string|max:255', 'nohp' => 'required|string|min:10|max:13',
'rental_price' => 'required|numeric',
'rental_start' => 'required|date|after_or_equal:today',
'rental_until' => 'required|date|after_or_equal:rental_start',
'land_name' => 'required|string|max:25',
'province_id' => 'required|exists:provinces,id',
'regency_id' => 'required|exists:regencies,id',
'district_id' => 'required|exists:districts,id',
'lat' => 'required|numeric',
'lng' => 'required|numeric',
], $customMessage); ], $customMessage);
if ($validator->fails()) { if ($validator->fails()) {
@ -74,8 +174,17 @@ public function update(Request $request, $id)
} }
$land = Land::find($id); $land = Land::find($id);
$land->name = $request->land_name; $land->land_name = $request->land_name;
$land->description = $request->description; $land->owner = $request->owner;
$land->no_hp = $request->nohp;
$land->rental_price = $request->rental_price;
$land->rental_start = $request->rental_start;
$land->rental_until = $request->rental_until;
$land->province_code = $request->province_id;
$land->regency_code = $request->regency_id;
$land->district_code = $request->district_id;
$land->latitude = $request->lat;
$land->longitude = $request->lng;
try { try {
$land->save(); $land->save();

14
app/Models/District.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class District extends Model
{
use HasFactory;
protected $table = 'districts';
protected $guarded = [];
}

View File

@ -10,9 +10,5 @@ class Land extends Model
use HasFactory; use HasFactory;
protected $table = 'land'; protected $table = 'land';
protected $guarded = [];
protected $fillable = [
'name',
'description',
];
} }

14
app/Models/Province.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Province extends Model
{
use HasFactory;
protected $table = 'provinces';
protected $guarded = [];
}

14
app/Models/Regency.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Regency extends Model
{
use HasFactory;
protected $table = 'regencies';
protected $guarded = [];
}

View File

@ -0,0 +1,31 @@
<?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(): void
{
Schema::create('provinces', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('alt_name');
$table->double('latitude');
$table->double('longitude');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('provinces');
}
};

View File

@ -0,0 +1,36 @@
<?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(): void
{
Schema::create('regencies', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('province_id');
$table->string('name');
$table->string('alt_name');
$table->double('latitude');
$table->double('longitude');
$table->timestamps();
});
Schema::table('regencies', function (Blueprint $table) {
$table->foreign('province_id')->references('id')->on('provinces');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('regencies');
}
};

View File

@ -0,0 +1,36 @@
<?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(): void
{
Schema::create('districts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('regency_id');
$table->string('name');
$table->string('alt_name');
$table->double('latitude');
$table->double('longitude');
$table->timestamps();
});
Schema::table('districts', function (Blueprint $table) {
$table->foreign('regency_id')->references('id')->on('regencies');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('districts');
}
};

View File

@ -13,8 +13,17 @@ public function up(): void
{ {
Schema::create('land', function (Blueprint $table) { Schema::create('land', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('land_name');
$table->text('description'); $table->string('owner');
$table->string('no_hp');
$table->string('rental_price');
$table->date('rental_start');
$table->date('rental_until');
$table->string('province_code');
$table->string('regency_code');
$table->string('district_code');
$table->string('latitude');
$table->string('longitude');
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -21,7 +21,9 @@ public function run(): void
$this->call([ $this->call([
UsersSeeder::class, UsersSeeder::class,
LandSeeder::class, ProvinceSeeder::class,
RegenciesSeeder::class,
// LandSeeder::class,
IndicatorSeeder::class, IndicatorSeeder::class,
RuleSeeder::class RuleSeeder::class
]); ]);

View File

@ -13,15 +13,13 @@ class LandSeeder extends Seeder
*/ */
public function run(): void public function run(): void
{ {
[ $lands = [
Land::create([ ['land_name' => 'Lahan 1', 'owner' => 'Pak Lahan 1', 'no_hp' => '08123456789', 'rental_price' => '2000000', 'rental_start' => '2025-01-01', 'rental_until' => '2025-06-30', 'province_code' => '11', 'regency_code' => '1101', 'district_code' => '110101', 'latitude' => '0.0', 'longitude' => '0.0'],
'name' => 'Land 1', ['land_name' => 'Lahan 2', 'owner' => 'Pak Lahan 2', 'no_hp' => '08123456789', 'rental_price' => '1500000', 'rental_start' => '2025-01-01', 'rental_until' => '2025-06-30', 'province_code' => '11', 'regency_code' => '1101', 'district_code' => '110101', 'latitude' => '0.0', 'longitude' => '0.0'],
'description' => 'Land 1 Description',
]),
Land::create([
'name' => 'Land 2',
'description' => 'Land 2 Description',
])
]; ];
foreach ($lands as $land) {
Land::create($land);
}
} }
} }

View File

@ -0,0 +1,261 @@
<?php
namespace Database\Seeders;
use App\Models\Province;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ProvinceSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$provinces = [
[
'id' => 11,
'name' => 'ACEH',
'alt_name' => 'ACEH',
'latitude' => 4.368550,
'longitude' => 97.025300,
],
[
'id' => 12,
'name' => 'SUMATERA UTARA',
'alt_name' => 'SUMATERA UTARA',
'latitude' => 2.192350,
'longitude' => 99.381220,
],
[
'id' => 13,
'name' => 'SUMATERA BARAT',
'alt_name' => 'SUMATERA BARAT',
'latitude' => -1.342250,
'longitude' => 100.076100,
],
[
'id' => 14,
'name' => 'RIAU',
'alt_name' => 'RIAU',
'latitude' => 0.500410,
'longitude' => 101.547580,
],
[
'id' => 15,
'name' => 'JAMBI',
'alt_name' => 'JAMBI',
'latitude' => -1.611570,
'longitude' => 102.779700,
],
[
'id' => 16,
'name' => 'SUMATERA SELATAN',
'alt_name' => 'SUMATERA SELATAN',
'latitude' => -3.126680,
'longitude' => 104.093060,
],
[
'id' => 17,
'name' => 'BENGKULU',
'alt_name' => 'BENGKULU',
'latitude' => -3.518680,
'longitude' => 102.535980,
],
[
'id' => 18,
'name' => 'LAMPUNG',
'alt_name' => 'LAMPUNG',
'latitude' => -4.855500,
'longitude' => 105.027300,
],
[
'id' => 19,
'name' => 'KEPULAUAN BANGKA BELITUNG',
'alt_name' => 'KEPULAUAN BANGKA BELITUNG',
'latitude' => -2.757750,
'longitude' => 107.583940,
],
[
'id' => 21,
'name' => 'KEPULAUAN RIAU',
'alt_name' => 'KEPULAUAN RIAU',
'latitude' => -0.154780,
'longitude' => 104.580370,
],
[
'id' => 31,
'name' => 'DKI JAKARTA',
'alt_name' => 'DKI JAKARTA',
'latitude' => 6.174500,
'longitude' => 106.822700,
],
[
'id' => 32,
'name' => 'JAWA BARAT',
'alt_name' => 'JAWA BARAT',
'latitude' => -6.889170,
'longitude' => 107.640470,
],
[
'id' => 33,
'name' => 'JAWA TENGAH',
'alt_name' => 'JAWA TENGAH',
'latitude' => -7.303240,
'longitude' => 110.004410,
],
[
'id' => 34,
'name' => 'DI YOGYAKARTA',
'alt_name' => 'DI YOGYAKARTA',
'latitude' => 7.795600,
'longitude' => 110.369500,
],
[
'id' => 35,
'name' => 'JAWA TIMUR',
'alt_name' => 'JAWA TIMUR',
'latitude' => -6.968510,
'longitude' => 113.980050,
],
[
'id' => 36,
'name' => 'BANTEN',
'alt_name' => 'BANTEN',
'latitude' => -6.445380,
'longitude' => 106.137560,
],
[
'id' => 51,
'name' => 'BALI',
'alt_name' => 'BALI',
'latitude' => -8.235660,
'longitude' => 115.122390,
],
[
'id' => 52,
'name' => 'NUSA TENGGARA BARAT',
'alt_name' => 'NUSA TENGGARA BARAT',
'latitude' => -8.121790,
'longitude' => 117.636960,
],
[
'id' => 53,
'name' => 'NUSA TENGGARA TIMUR',
'alt_name' => 'NUSA TENGGARA TIMUR',
'latitude' => -8.565680,
'longitude' => 120.697860,
],
[
'id' => 61,
'name' => 'KALIMANTAN BARAT',
'alt_name' => 'KALIMANTAN BARAT',
'latitude' => -0.132240,
'longitude' => 111.096890,
],
[
'id' => 62,
'name' => 'KALIMANTAN TENGAH',
'alt_name' => 'KALIMANTAN TENGAH',
'latitude' => -1.499580,
'longitude' => 113.290330,
],
[
'id' => 63,
'name' => 'KALIMANTAN SELATAN',
'alt_name' => 'KALIMANTAN SELATAN',
'latitude' => -2.943480,
'longitude' => 115.375650,
],
[
'id' => 64,
'name' => 'KALIMANTAN TIMUR',
'alt_name' => 'KALIMANTAN TIMUR',
'latitude' => 0.788440,
'longitude' => 116.242000,
],
[
'id' => 65,
'name' => 'KALIMANTAN UTARA',
'alt_name' => 'KALIMANTAN UTARA',
'latitude' => 2.725940,
'longitude' => 116.911000,
],
[
'id' => 71,
'name' => 'SULAWESI UTARA',
'alt_name' => 'SULAWESI UTARA',
'latitude' => 0.655570,
'longitude' => 124.090150,
],
[
'id' => 72,
'name' => 'SULAWESI TENGAH',
'alt_name' => 'SULAWESI TENGAH',
'latitude' => -1.693780,
'longitude' => 120.808860,
],
[
'id' => 73,
'name' => 'SULAWESI SELATAN',
'alt_name' => 'SULAWESI SELATAN',
'latitude' => -3.644670,
'longitude' => 119.947190,
],
[
'id' => 74,
'name' => 'SULAWESI TENGGARA',
'alt_name' => 'SULAWESI TENGGARA',
'latitude' => -3.549120,
'longitude' => 121.727960,
],
[
'id' => 75,
'name' => 'GORONTALO',
'alt_name' => 'GORONTALO',
'latitude' => 0.718620,
'longitude' => 122.455590,
],
[
'id' => 76,
'name' => 'SULAWESI BARAT',
'alt_name' => 'SULAWESI BARAT',
'latitude' => -2.497450,
'longitude' => 119.391900,
],
[
'id' => 81,
'name' => 'MALUKU',
'alt_name' => 'MALUKU',
'latitude' => -3.118840,
'longitude' => 129.420780,
],
[
'id' => 82,
'name' => 'MALUKU UTARA',
'alt_name' => 'MALUKU UTARA',
'latitude' => 0.630120,
'longitude' => 127.972020,
],
[
'id' => 91,
'name' => 'PAPUA BARAT',
'alt_name' => 'PAPUA BARAT',
'latitude' => -1.384240,
'longitude' => 132.902530,
],
[
'id' => 94,
'name' => 'PAPUA',
'alt_name' => 'PAPUA',
'latitude' => -3.988570,
'longitude' => 138.348530,
],
];
foreach ($provinces as $province) {
Province::create($province);
}
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -1,11 +1,550 @@
function updateData(land) { var map, mapEdit;
var form = document.getElementById("edit-form"); var currentMarker,
var landName = document.getElementById("landname-edit-field"); currentMarkerEdit = null;
var status = document.getElementById("status-edit-field");
landName.value = land.name; var form = document.getElementById("add-form");
status.value = land.description; var formEdit = document.getElementById("edit-form");
form.action = "/data-lahan/" + land.id; var provinceField = form.querySelector("#province-field");
var provinceVal = new Choices(provinceField);
var regencyContainer = form.querySelector("#regency-container");
var regencyField = form.querySelector("#regency-field");
var regencyVal = new Choices(regencyField, {
shouldSort: false,
});
var regencyEditContainer = formEdit.querySelector("#regency-edit-container");
var regencyEditField = formEdit.querySelector("#regency-edit-field");
var regencyEditVal = new Choices(regencyEditField, {
shouldSort: false,
});
var districtContainer = form.querySelector("#district-container");
var districtField = form.querySelector("#district-field");
var districtVal = new Choices(districtField, {
shouldSort: false,
});
var districtEditContainer = formEdit.querySelector("#district-edit-container");
var districtEditField = formEdit.querySelector("#district-edit-field");
var districtEditVal = new Choices(districtEditField, {
shouldSort: false,
});
var mapContainer = form.querySelector("#map-container");
var latField = form.querySelector("#lat");
var lngField = form.querySelector("#lng");
var mapEditConatiner = formEdit.querySelector("#map-edit-container");
var latEditField = formEdit.querySelector("#lat-edit");
var lngEditField = formEdit.querySelector("#lng-edit");
var loading = form.querySelector("#loading");
var loadingEdit = formEdit.querySelector("#loading-edit");
var btnContainer = form.querySelector("#add-footer");
var btnEditContainer = formEdit.querySelector("#edit-footer");
document.addEventListener("DOMContentLoaded", function () {
map = L.map("map", {
attributionControl: false,
}).setView([-8.157416852745705, 113.72281580436439], 16);
mapEdit = L.map("map-edit", {
attributionControl: false,
}).setView([-8.157416852745705, 113.72281580436439], 16);
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
maxZoom: 19,
}).addTo(map);
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
maxZoom: 19,
}).addTo(mapEdit);
var iconMarker = L.icon({
iconUrl: "/assets/images/marker.png",
iconSize: [50, 50],
iconAnchor: [25, 50],
popupAnchor: [0, -50],
});
currentMarkerEdit = L.marker([-8.157416852745705, 113.72281580436439], {
icon: iconMarker,
draggable: true,
})
.addTo(mapEdit)
.bindPopup(
`<div class="text-center"><b>Anda berada di sini</b><br />Silahkan priksa lokasi petamu sudah benar.</div>`
);
$("#showModal").on("shown.bs.modal", function () {
map.invalidateSize();
});
$("#editModal").on("shown.bs.modal", function () {
mapEdit.invalidateSize();
});
map.on("click", onMapClick);
});
function validatePhoneNumber(input) {
input.value = input.value.replace(/\D/g, "");
if (input.value.length < 10 || input.value.length > 13) {
input.setCustomValidity("Nomor telepon tidak valid");
} else {
input.setCustomValidity("");
}
}
function validatePrice(input) {
let value = input.value.replace(/\D/g, "");
let formatted = new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
minimumFractionDigits: 0,
}).format(value);
input.value = formatted.replace("Rp", "").trim();
}
function showmap(districtId) {
if (!navigator.geolocation) {
alert("Geolocation tidak didukung oleh browser ini.");
return;
}
navigator.geolocation.getCurrentPosition(
function (position) {
mapContainer.style.display = "block";
map.invalidateSize();
mapEditConatiner.style.display = "block";
mapEdit.invalidateSize();
btnContainer.style.display = "block";
btnEditContainer.style.display = "block";
var lat = position.coords.latitude;
var lng = position.coords.longitude;
console.log(lat, lng);
map.setView([lat, lng], 16);
mapEdit.setView([lat, lng], 16);
if (currentMarker || currentMarkerEdit) {
map.removeLayer(currentMarker);
mapEdit.removeLayer(currentMarkerEdit);
}
var iconMarker = L.icon({
iconUrl: "/assets/images/marker.png",
iconSize: [50, 50],
iconAnchor: [25, 50],
popupAnchor: [0, -50],
});
currentMarker = L.marker([lat, lng], {
icon: iconMarker,
draggable: true,
}).addTo(map);
currentMarkerEdit = L.marker([lat, lng], {
icon: iconMarker,
draggable: true,
}).addTo(mapEdit);
currentMarker.on("dragend", onMapDragend);
currentMarkerEdit.on("dragend", onMapDragend);
currentMarker
.bindPopup(
`<div class="text-center"><b>Anda berada di sini</b><br />Silahkan priksa lokasi petamu sudah benar.</div>`
)
.openPopup();
currentMarkerEdit
.bindPopup(
`<div class="text-center"><b>Anda berada di sini</b><br />Silahkan priksa lokasi petamu sudah benar.</div>`
)
.openPopup();
latField.value = lat;
lngField.value = lng;
latEditField.value = lat;
lngEditField.value = lng;
},
function (error) {
alert("Error: " + error.message);
}
);
}
function onMapClick(e) {
var lat = e.latlng.lat;
var lng = e.latlng.lng;
if (!currentMarker) {
currentMarker = L.marker(e.latlng).addTo(map);
} else {
currentMarker.setLatLng(e.latlng);
}
currentMarker.on("dragend", onMapDragend);
currentMarker
.bindPopup(
`<div class="text-center"><b>Anda berada di sini</b><br />Silahkan priksa lokasi petamu sudah benar.</div>`
)
.openPopup();
latField.value = lat;
lngField.value = lng;
}
function onMapDragend() {
if (!currentMarker) return;
var coordinates = currentMarker.getLatLng();
currentMarker
.setLatLng(coordinates)
.bindPopup(
`<div class="text-center"><b>Anda berada di sini</b><br />Silahkan priksa lokasi petamu sudah benar.</div>`
)
.openPopup();
latField.value = coordinates.lat;
lngField.value = coordinates.lng;
}
function getProvinces(provinceId) {
return new Promise(function (resolve, reject) {
$.ajax({
url: "/location/get-province",
type: "GET",
success: function (response) {
if (response.success) {
const province = response.data.find(
(province) => province.id == provinceId
);
resolve(province);
} else {
reject(new Error("Terjadi kesalahan saat mengambil data"));
}
},
error: function (xhr, status, error) {
reject(new Error("Terjadi kesalahan saat mengambil data"));
},
});
});
}
function getRegencies(provinceId) {
regencyContainer.style.display = "none";
regencyEditContainer.style.display = "none";
districtContainer.style.display = "none";
districtEditContainer.style.display = "none";
loading.style.display = "block";
loadingEdit.style.display = "block";
mapContainer.style.display = "none";
mapEditConatiner.style.display = "none";
const url = "/location/get-regency/" + provinceId;
$.ajax({
url: url,
type: "GET",
success: function (response) {
if (response.success) {
loading.style.display = "none";
loadingEdit.style.display = "none";
const data = response.data;
regencyVal.clearStore();
regencyVal.clearChoices();
regencyEditVal.clearStore();
regencyEditVal.clearChoices();
regencyVal.value = "";
regencyVal.setChoices([
{
value: "",
label: "Pilih Kabupaten",
selected: true,
disabled: true,
},
]);
regencyEditVal.value = "";
regencyEditVal.setChoices([
{
value: "",
label: "Pilih Kabupaten",
selected: true,
disabled: true,
},
]);
if (Array.isArray(data)) {
regencyVal.setChoices(
data.map((regency) => ({
value: regency.id,
label: regency.name,
selected: false,
disabled: false,
}))
);
regencyEditVal.setChoices(
data.map((regency) => ({
value: regency.id,
label: regency.name,
selected: false,
disabled: false,
}))
);
regencyContainer.style.display = "block";
regencyEditContainer.style.display = "block";
} else {
mapContainer.style.display = "block";
mapContainer.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
mapEditConatiner.style.display = "block";
mapEditConatiner.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
}
}
},
error: function (xhr, status, error) {
mapContainer.style.display = "block";
mapContainer.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
mapEditConatiner.style.display = "block";
mapEditConatiner.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
},
});
}
function getDistricts(regencyId) {
districtContainer.style.display = "none";
districtEditContainer.style.display = "none";
loading.style.display = "block";
loadingEdit.style.display = "block";
mapContainer.style.display = "none";
mapEditConatiner.style.display = "none";
const url = "/location/get-district/" + regencyId;
$.ajax({
url: url,
type: "GET",
success: function (response) {
if (response.success) {
loading.style.display = "none";
loadingEdit.style.display = "none";
const data = response.data;
districtVal.clearStore();
districtVal.clearChoices();
districtEditVal.clearStore();
districtEditVal.clearChoices();
districtVal.value = "";
districtVal.setChoices([
{
value: "",
label: "Pilih Kecamatan",
selected: true,
disabled: true,
},
]);
districtEditVal.value = "";
districtEditVal.setChoices([
{
value: "",
label: "Pilih Kecamatan",
selected: true,
disabled: true,
},
]);
if (Array.isArray(data)) {
districtVal.setChoices(
data.map((district) => ({
value: district.id,
label: district.name,
selected: false,
disabled: false,
}))
);
districtEditVal.setChoices(
data.map((district) => ({
value: district.id,
label: district.name,
selected: false,
disabled: false,
}))
);
districtContainer.style.display = "block";
districtEditContainer.style.display = "block";
} else {
mapContainer.style.display = "block";
mapContainer.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
mapEditConatiner.style.display = "block";
mapEditConatiner.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
}
}
},
error: function (xhr, status, error) {
mapContainer.style.display = "block";
mapContainer.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
mapEditConatiner.style.display = "block";
mapEditConatiner.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
},
});
}
async function updateData(land) {
var ownerEditField = formEdit.querySelector("#owner-edit-field");
var noHpEditField = formEdit.querySelector("#nohp-edit-field");
var rentalPriceEditField = formEdit.querySelector(
"#rentalprice-edit-field"
);
var rentalStartEditField = formEdit.querySelector(
"#rentalstart-edit-field"
);
var rentalUntilEditField = formEdit.querySelector(
"#rentaluntil-edit-field"
);
var landNameEditField = formEdit.querySelector("#landname-edit-field");
var provinceEditField = formEdit.querySelector("#province-edit-field");
var provinceEditVal = new Choices(provinceEditField);
let rentalPrice = new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
minimumFractionDigits: 0,
}).format(land.rental_price);
ownerEditField.value = land.owner;
noHpEditField.value = land.no_hp;
rentalPriceEditField.value = rentalPrice.replace(/Rp\s?/g, "").trim();
rentalStartEditField.value = land.rental_start;
rentalUntilEditField.value = land.rental_until;
landNameEditField.value = land.land_name;
provinceEditField.value = land.province_code;
try {
const province = await getProvinces(land.province_code);
provinceEditVal.setChoices([
{
value: province.id,
label: province.name,
selected: true,
disabled: true,
},
]);
$.ajax({
type: "GET",
url: "/location/get-regency/" + land.province_code,
success: function (response) {
if (response.success) {
const dataRegencies = response.data;
const regencies = response.data.find(
(regency) => regency.id === parseInt(land.regency_code)
);
regencyEditVal.setChoices([
{
value: regencies.id,
label: regencies.name,
selected: true,
disabled: true,
},
]);
if (Array.isArray(dataRegencies)) {
regencyEditVal.setChoices(
dataRegencies.map((regency) => ({
value: regency.id,
label: regency.name,
selected: false,
disabled: false,
}))
);
} else {
mapEditConatiner.style.display = "block";
mapEditConatiner.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
}
}
},
});
$.ajax({
type: "GET",
url: "/location/get-district/" + land.regency_code,
success: function (response) {
if (response.success) {
const dataDistricts = response.data;
const districts = response.data.find(
(district) =>
district.id === parseInt(land.district_code)
);
districtEditVal.setChoices([
{
value: districts.id,
label: districts.name,
selected: true,
disabled: true,
},
]);
if (Array.isArray(dataDistricts)) {
districtEditVal.setChoices(
dataDistricts.map((district) => ({
value: district.id,
label: district.name,
selected: false,
disabled: false,
}))
);
} else {
mapEditConatiner.style.display = "block";
mapEditConatiner.innerHTML =
"<p class='text-center text-muted'>Terjadi kesalaahan saat mengambil data, silahkan coba beberapa saat lagi</p>";
}
}
},
});
mapEdit.setView([land.latitude, land.longitude], 16);
currentMarkerEdit
.setLatLng([land.latitude, land.longitude])
.openPopup();
latEditField.value = land.latitude;
lngEditField.value = land.longitude;
formEdit.action = "/data-lahan/" + land.id;
} catch (error) {
console.log(error);
}
} }
function deleteData(id) { function deleteData(id) {
@ -15,7 +554,7 @@ function deleteData(id) {
var perPage = 10, var perPage = 10,
options = { options = {
valueNames: ["id", "land_name", "status"], valueNames: ["id", "land_name", "owner", "rental_price", "status"],
page: perPage, page: perPage,
pagination: !0, pagination: !0,
plugins: [ListPagination({ left: 2, right: 2 })], plugins: [ListPagination({ left: 2, right: 2 })],

5966
public/assets/libs/jquery/jquery.min.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
<link href="assets/css/app.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/app.min.css" rel="stylesheet" type="text/css" />
<!-- custom Css--> <!-- custom Css-->
<link href="assets/css/custom.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/custom.min.css" rel="stylesheet" type="text/css" />
@stack('other-css')
</head> </head>
@ -605,6 +605,7 @@ class="form-check-input">
<!-- App js --> <!-- App js -->
<script src="assets/js/app.js"></script> <script src="assets/js/app.js"></script>
<script src="assets/libs/jquery/jquery.min.js"></script>
</body> </body>
</html> </html>

View File

@ -1,6 +1,24 @@
@extends('layouts.app') @extends('layouts.app')
@push('title', 'Data Tanah') @push('title', 'Data Tanah')
@section('content') @section('content')
@push('other-css')
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
<style>
#map {
height: 200px;
width: 100%;
z-index: 0;
}
#map-edit {
height: 200px;
width: 100%;
z-index: 0;
}
</style>
@endpush
<div class="page-content"> <div class="page-content">
<div class="container-fluid"> <div class="container-fluid">
@ -57,7 +75,9 @@ class="ri-add-line align-bottom me-1"></i> Tambah</button>
No No
</th> </th>
<th class="sort" data-sort="land_name">Nama Lahan</th> <th class="sort" data-sort="land_name">Nama Lahan</th>
<th class="sort" data-sort="description">Deskripsi</th> <th class="sort" data-sort="owner">Pemilik</th>
<th class="sort" data-sort="rental_price">Harga Sewa</th>
<th class="sort" data-sort="length_of_ease">Lama Sewa</th>
<th class="sort" data-sort="action">Action</th> <th class="sort" data-sort="action">Action</th>
</tr> </tr>
</thead> </thead>
@ -67,8 +87,14 @@ class="ri-add-line align-bottom me-1"></i> Tambah</button>
<td class="no">{{ $loop->iteration }}</td> <td class="no">{{ $loop->iteration }}</td>
<td class="id" style="display:none;"><a href="javascript:void(0);" <td class="id" style="display:none;"><a href="javascript:void(0);"
class="fw-medium link-primary">#VZ2101</a></td> class="fw-medium link-primary">#VZ2101</a></td>
<td class="land_name">{{ $land->name }}</td> <td class="land_name">{{ $land->land_name }}</td>
<td class="status"><span>{{ $land->description }}</span></td> <td class="owner">{{ $land->owner }}</td>
<td class="rental_price">Rp.{{ number_format($land->rental_price) }}
</td>
<td class="status">
<span>{{ \Carbon\Carbon::parse($land->length_of_ease)->diffInDays(\Carbon\Carbon::parse($land->rental_until)) }}
Hari</span>
</td>
<td> <td>
<div class="d-flex gap-2 justify-content-center"> <div class="d-flex gap-2 justify-content-center">
<div class="edit"> <div class="edit">
@ -124,7 +150,7 @@ class="fw-medium link-primary">#VZ2101</a></td>
<div class="modal-dialog modal-dialog-centered"> <div class="modal-dialog modal-dialog-centered">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header bg-light p-3"> <div class="modal-header bg-light p-3">
<h5 class="modal-title" id="exampleModalLabel"></h5> <h5 class="modal-title" id="exampleModalLabel">Tambah Data Lahan</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
id="close-modal"></button> id="close-modal"></button>
</div> </div>
@ -139,6 +165,61 @@ class="fw-medium link-primary">#VZ2101</a></td>
readonly /> readonly />
</div> </div>
<div class="mb-3">
<label for="owner-field" class="form-label">Pemilik Lahan</label>
<input type="text" id="owner-field" class="form-control" name="owner"
value="{{ old('owner') }}" placeholder="Masukan Nama Pemilik Lahan" required />
<div class="invalid-feedback">
Masukan Nama Pemilik Lahan
</div>
</div>
<div class="mb-3">
<label for="nohp-field" class="form-label">Nomor HP</label>
<input type="text" id="nohp-field" class="form-control" name="nohp"
value="{{ old('nohp') }}" placeholder="Masukan Nomor HP" required
oninput="validatePhoneNumber(this)" />
<div class="invalid-feedback">
Masukan Nomor HP
</div>
</div>
<div class="mb-3">
<label for="rentalprice-field" class="form-label">Harga Sewa</label>
<input type="text" id="rentalprice-field" class="form-control"
name="rental_price" value="{{ old('rental_price') }}"
placeholder="Masukan Harga Sewa" required oninput="validatePrice(this)" />
<div class="invalid-feedback">
Masukan Harga Sewa
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="rentalstart-field" class="form-label">Mulai Dari</label>
<input type="date" id="rentalstart-field" class="form-control"
name="rental_start" value="{{ old('rental_start') }}"
min="{{ date('Y-m-d') }}" placeholder="Masukan Tanggal Mulai" required />
<div class="invalid-feedback">
Masukan Tanggal Mulai
</div>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="rentaluntil-field" class="form-label">Sampai</label>
<input type="date" id="rentaluntil-field" class="form-control"
name="rental_until" value="{{ old('rental_start') }}"
min="{{ date('Y-m-d') }}" placeholder="Masukan Tanggal Sampai"
required />
<div class="invalid-feedback">
Masukan Tanggal Sampai
</div>
</div>
</div>
</div>
<div class="mb-3"> <div class="mb-3">
<label for="landname-field" class="form-label">Nama Lahan</label> <label for="landname-field" class="form-label">Nama Lahan</label>
<input type="text" id="landname-field" class="form-control" name="land_name" <input type="text" id="landname-field" class="form-control" name="land_name"
@ -148,16 +229,63 @@ class="fw-medium link-primary">#VZ2101</a></td>
</div> </div>
</div> </div>
<div> <div class="mb-3">
<label for="status-field" class="form-label">Deskripsi</label> <label for="province-field" class="form-label">Provinsi</label>
<textarea name="description" id="status-field" rows="5" placeholder="Masukan Deskripsi" class="form-control" <select name="province_id" id="province-field" class="form-control" required
required>{{ old('description') }}</textarea> onchange="getRegencies(this.value)">
<option value="" selected disabled>Pilih Provinsi</option>
@foreach ($provinces as $province)
<option value="{{ $province->id }}"
{{ old('province_id') == $province->id ? 'selected' : '' }}>
{{ $province->name }}</option>
@endforeach
</select>
<div class="invalid-feedback"> <div class="invalid-feedback">
Masukan Deskripsi Harap Pilih Provinsi
</div>
</div>
<div class="mb-3" id="regency-container" style="display: none">
<label for="regency-field" class="form-label">Kabupaten atau Kota</label>
<select name="regency_id" id="regency-field" class="form-control" required
onchange="getDistricts(this.value)">
<option value="" selected disabled>Pilih Kabupaten atau Kota</option>
</select>
<div class="invalid-feedback">
Harap Pilih Kabupaten atau Kota
</div>
</div>
<div class="mb-3" id="district-container" style="display: none">
<label for="district-field" class="form-label">Kecamatan</label>
<select name="district_id" id="district-field" class="form-control" required
onchange="showmap(this.value)">
<option value="" selected disabled>Pilih Kecamatan</option>
</select>
<div class="invalid-feedback">
Harap Pilih Kecamatan
</div>
</div>
<div id="loading" class="text-center" style="display: none">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div id="map-container" style="display: none">
<label for="map" class="form-label">Lokasi</label>
<div id="map"></div>
<div class="mt-3">
<input type="hidden" name="lat" id="lat" class="form-control"
readonly>
<input type="hidden" name="lng" id="lng" class="form-control"
readonly>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer" id="add-footer" style="display: none">
<div class="hstack gap-2 justify-content-end"> <div class="hstack gap-2 justify-content-end">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Tutup</button> <button type="button" class="btn btn-light" data-bs-dismiss="modal">Tutup</button>
<button type="submit" class="btn btn-success" id="add-btn">Simpan</button> <button type="submit" class="btn btn-success" id="add-btn">Simpan</button>
@ -189,19 +317,127 @@ class="fw-medium link-primary">#VZ2101</a></td>
readonly /> readonly />
</div> </div>
<div class="mb-3">
<label for="owner-edit-field" class="form-label">Pemilik Lahan</label>
<input type="text" id="owner-edit-field" class="form-control" name="owner"
value="{{ old('owner') }}" placeholder="Masukan Nama Pemilik Lahan" required />
<div class="invalid-feedback">
Masukan Nama Pemilik Lahan
</div>
</div>
<div class="mb-3">
<label for="nohp-edit-field" class="form-label">Nomor HP</label>
<input type="text" id="nohp-edit-field" class="form-control" name="nohp"
value="{{ old('nohp') }}" placeholder="Masukan Nomor HP" required
oninput="validatePhoneNumber(this)" />
<div class="invalid-feedback">
Masukan Nomor HP
</div>
</div>
<div class="mb-3">
<label for="rentalprice-edit-field" class="form-label">Harga Sewa</label>
<input type="text" id="rentalprice-edit-field" class="form-control"
name="rental_price" value="{{ old('rental_price') }}"
placeholder="Masukan Harga Sewa" required oninput="validatePrice(this)" />
<div class="invalid-feedback">
Masukan Harga Sewa
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="rentalstart-edit-field" class="form-label">Mulai Dari</label>
<input type="date" id="rentalstart-edit-field" class="form-control"
name="rental_start" value="{{ old('rental_start') }}"
min="{{ date('Y-m-d') }}" placeholder="Masukan Tanggal Mulai" required />
<div class="invalid-feedback">
Masukan Tanggal Mulai
</div>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="rentaluntil-edit-field" class="form-label">Sampai</label>
<input type="date" id="rentaluntil-edit-field" class="form-control"
name="rental_until" value="{{ old('rental_start') }}"
min="{{ date('Y-m-d') }}" placeholder="Masukan Tanggal Sampai"
required />
<div class="invalid-feedback">
Masukan Tanggal Sampai
</div>
</div>
</div>
</div>
<div class="mb-3"> <div class="mb-3">
<label for="landname-edit-field" class="form-label">Nama Lahan</label> <label for="landname-edit-field" class="form-label">Nama Lahan</label>
<input type="text" id="landname-edit-field" class="form-control" name="land_name" <input type="text" id="landname-edit-field" class="form-control" name="land_name"
value="{{ old('land_name') }}" placeholder="Masukan Nama Lahan" required /> value="{{ old('land_name') }}" placeholder="Masukan Nama Lahan" required />
<div class="invalid-feedback">
Masukan Nama Lahan
</div>
</div> </div>
<div> <div class="mb-3">
<label for="status-edit-field" class="form-label">Deskripsi</label> <label for="province-edit-field" class="form-label">Provinsi</label>
<textarea name="description" id="status-edit-field" rows="5" placeholder="Masukan Deskripsi" <select name="province_id" id="province-edit-field" class="form-control" required
class="form-control" required>{{ old('description') }}</textarea> onchange="getRegencies(this.value)">
<option value="" selected disabled>Pilih Provinsi</option>
@foreach ($provinces as $province)
<option value="{{ $province->id }}"
{{ old('province_id') == $province->id ? 'selected' : '' }}>
{{ $province->name }}</option>
@endforeach
</select>
<div class="invalid-feedback">
Harap Pilih Provinsi
</div>
</div>
<div class="mb-3" id="regency-edit-container">
<label for="regency-edit-field" class="form-label">Kabupaten atau Kota</label>
<select name="regency_id" id="regency-edit-field" class="form-control" required
onchange="getDistricts(this.value)">
<option value="" selected disabled>Pilih Kabupaten atau Kota</option>
</select>
<div class="invalid-feedback">
Harap Pilih Kabupaten atau Kota
</div>
</div>
<div class="mb-3" id="district-edit-container">
<label for="district-edit-field" class="form-label">Kecamatan</label>
<select name="district_id" id="district-edit-field" class="form-control" required
onchange="showmap(this.value)">
<option value="" selected disabled>Pilih Kecamatan</option>
</select>
<div class="invalid-feedback">
Harap Pilih Kecamatan
</div>
</div>
<div id="loading-edit" class="text-center" style="display: none">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div id="map-edit-container">
<label for="map-edit" class="form-label">Lokasi</label>
<div id="map-edit"></div>
<div class="mt-3">
<input type="hidden" name="lat" id="lat-edit" class="form-control"
readonly>
<input type="hidden" name="lng" id="lng-edit" class="form-control"
readonly>
</div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer" id="edit-footer">
<div class="hstack gap-2 justify-content-end"> <div class="hstack gap-2 justify-content-end">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Tutup</button> <button type="button" class="btn btn-light" data-bs-dismiss="modal">Tutup</button>
<button type="submit" class="btn btn-success" id="add-btn">Ubah</button> <button type="submit" class="btn btn-success" id="add-btn">Ubah</button>
@ -260,5 +496,9 @@ class="form-control" required>{{ old('description') }}</textarea>
<script src="assets/js/pages/customJs/master-data/lahan/index.js"></script> <script src="assets/js/pages/customJs/master-data/lahan/index.js"></script>
<script src="assets/js/pages/form-validation.init.js"></script> <script src="assets/js/pages/form-validation.init.js"></script>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
@endpush @endpush
@endsection @endsection

View File

@ -7,6 +7,7 @@
use App\Http\Controllers\Auth\RegisteredUserController; use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\Auth\TwoStepVerifyController; use App\Http\Controllers\Auth\TwoStepVerifyController;
use App\Http\Controllers\DashboardController; use App\Http\Controllers\DashboardController;
use App\Http\Controllers\LocationController;
use App\Http\Controllers\MasterData\IndicatorController; use App\Http\Controllers\MasterData\IndicatorController;
use App\Http\Controllers\MasterData\LandController; use App\Http\Controllers\MasterData\LandController;
use App\Http\Controllers\MasterData\RuleController; use App\Http\Controllers\MasterData\RuleController;
@ -59,6 +60,12 @@
Route::middleware(['auth', 'verifiedAcount'])->group(function () { Route::middleware(['auth', 'verifiedAcount'])->group(function () {
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('auth.logout'); Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('auth.logout');
Route::prefix('location')->controller(LocationController::class)->name('location.')->group(function () {
Route::get('/get-province', 'getProvinces')->name('get_provinces');
Route::get('/get-regency/{id}', 'getRegencies')->name('get_regencies');
Route::get('/get-district/{id}', 'getDistricts')->name('get_districts');
});
Route::middleware('admin')->group(function () { Route::middleware('admin')->group(function () {
Route::get('/dashboard-admin', [DashboardController::class, 'admin'])->name('dashboard.admin'); Route::get('/dashboard-admin', [DashboardController::class, 'admin'])->name('dashboard.admin');