partial update spatial plannings crud

This commit is contained in:
arifal
2025-02-19 12:08:18 +07:00
parent e8da7193ef
commit 54146c8c08
6 changed files with 217 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\SpatialPlanning;
use Illuminate\Http\Request;
class SpatialPlanningsController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$query = SpatialPlanning::query()->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);
}
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SpatialPlanningsController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('spatial-plannings.index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('spatial-plannings.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
return view('spatial-plannings.update');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}