63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?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);
|
|
}
|
|
}
|
|
}
|