Commit 625a5b77 by Triyah Fatmawati

Update route api saku

parent 0c1fc5ed
...@@ -10,27 +10,32 @@ ...@@ -10,27 +10,32 @@
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();
foreach ($penelaah as $key => $pen) { if($penelaah){
$dataTelaah[] = [ foreach ($penelaah as $key => $pen) {
'id' => $pen->id, $dataTelaah[] = [
'nama' => $pen->nama, 'id' => $pen->id,
'nip' => $pen->nip, 'nama' => $pen->nama,
'nik' => $pen->nik, 'nip' => $pen->nip,
'unit' => $pen->unit, 'nik' => $pen->nik,
'created_at' => $pen->created_at, 'unit' => $pen->unit,
'judul' => $pen->penelaah->judul, 'created_at' => $pen->created_at,
'kode_kategori' => $pen->penelaah->kategori->kode_kategori, 'judul' => $pen->penelaah->judul,
'nama_kategori' => $pen->penelaah->kategori->nama_kategori, 'kode_kategori' => $pen->penelaah->kategori->kode_kategori,
'poin_saku' => $pen->penelaah->kategori->poin_saku, 'nama_kategori' => $pen->penelaah->kategori->nama_kategori,
'tahun' => $pen->penelaah->tahun 'poin_saku' => $pen->penelaah->kategori->poin_saku,
]; '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