diff --git a/app/Http/Controllers/Api/SpatialPlanningsController.php b/app/Http/Controllers/Api/SpatialPlanningsController.php new file mode 100644 index 0000000..3c75aee --- /dev/null +++ b/app/Http/Controllers/Api/SpatialPlanningsController.php @@ -0,0 +1,62 @@ +orderBy('id', 'desc'); + if ($request->has("search") &&!empty($request->get("search"))) { + $query = $query->where("name", "LIKE", "%{$request->get("search")}%") + ->orWhere("nomor", "LIKE", "%{$request->get("search")}%"); + } + $query = $query->paginate(); + return response()->json($query); + } + + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + try{ + SpatialPlanning::destroy($id); + return response()->json([ + 'message' => 'Data berhasil dihapus' + ], 200); + }catch(\Exception $e){ + return response()->json([ + 'error' => $e->getMessage() + ], 500); + } + } +} diff --git a/app/Http/Controllers/SpatialPlanningsController.php b/app/Http/Controllers/SpatialPlanningsController.php new file mode 100644 index 0000000..6d6f137 --- /dev/null +++ b/app/Http/Controllers/SpatialPlanningsController.php @@ -0,0 +1,64 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => ['required','string','max:255'], + 'kbli' => ['required','string','max:255'], + 'kegiatan' => ['required','string'], + 'luas' => ['required','numeric','regex:/^\d{1,16}(\.\d{1,2})?$/'], + 'lokasi' => ['required','string'], + 'nomor' => ['required','string','max:255',Rule::unique('spatial_plannings')->ignore($this->id)], + 'tanggal' => ['required','date'], + ]; + } +} diff --git a/app/Models/SpatialPlanning.php b/app/Models/SpatialPlanning.php new file mode 100644 index 0000000..bcf914f --- /dev/null +++ b/app/Models/SpatialPlanning.php @@ -0,0 +1,19 @@ +id(); + $table->string('name'); + $table->string('kbli'); + $table->text('kegiatan'); + $table->decimal('luas',18,2); + $table->text('lokasi'); + $table->string('nomor')->unique(); + $table->date('sp_date'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('spatial_plannings'); + } +}; diff --git a/resources/views/spatial-plannings/index.blade.php b/resources/views/spatial-plannings/index.blade.php new file mode 100644 index 0000000..5187f80 --- /dev/null +++ b/resources/views/spatial-plannings/index.blade.php @@ -0,0 +1,3 @@ +
+ +