Commit 625a5b77 by Triyah Fatmawati

Update route api saku

parent 0c1fc5ed
...@@ -10,13 +10,17 @@ ...@@ -10,13 +10,17 @@
class ApiSakuController extends Controller class ApiSakuController extends Controller
{ {
public function index(){ public function index($tahun){
$dataTelaah = [];
$penelaah = Penelaah::query() $penelaah = Penelaah::query()
->with('penelaah') ->whereHas('penelaah', function($query) use ($tahun) {
// ->where('created_at', '<', '2024-05-20') $query->where('tahun', $tahun);
})
->orderBy('nip') ->orderBy('nip')
->get(); ->get();
if($penelaah){
foreach ($penelaah as $key => $pen) { foreach ($penelaah as $key => $pen) {
$dataTelaah[] = [ $dataTelaah[] = [
'id' => $pen->id, 'id' => $pen->id,
...@@ -32,6 +36,7 @@ public function index(){ ...@@ -32,6 +36,7 @@ public function index(){
'tahun' => $pen->penelaah->tahun 'tahun' => $pen->penelaah->tahun
]; ];
} }
}
return response()->json($dataTelaah); return response()->json($dataTelaah);
} }
......
...@@ -19,5 +19,5 @@ ...@@ -19,5 +19,5 @@
return $request->user(); return $request->user();
}); });
Route::get('/saku', [ApiSakuController::class, 'index']); Route::get('/saku/{tahun}', [ApiSakuController::class, 'index']);
Route::get('/saku1', [ApiSakuController::class, 'saku1']); Route::get('/saku1', [ApiSakuController::class, 'saku1']);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment