Commit 625a5b77 by Triyah Fatmawati

Update route api saku

parent 0c1fc5ed
......@@ -10,27 +10,32 @@
class ApiSakuController extends Controller
{
public function index(){
public function index($tahun){
$dataTelaah = [];
$penelaah = Penelaah::query()
->with('penelaah')
// ->where('created_at', '<', '2024-05-20')
->whereHas('penelaah', function($query) use ($tahun) {
$query->where('tahun', $tahun);
})
->orderBy('nip')
->get();
foreach ($penelaah as $key => $pen) {
$dataTelaah[] = [
'id' => $pen->id,
'nama' => $pen->nama,
'nip' => $pen->nip,
'nik' => $pen->nik,
'unit' => $pen->unit,
'created_at' => $pen->created_at,
'judul' => $pen->penelaah->judul,
'kode_kategori' => $pen->penelaah->kategori->kode_kategori,
'nama_kategori' => $pen->penelaah->kategori->nama_kategori,
'poin_saku' => $pen->penelaah->kategori->poin_saku,
'tahun' => $pen->penelaah->tahun
];
if($penelaah){
foreach ($penelaah as $key => $pen) {
$dataTelaah[] = [
'id' => $pen->id,
'nama' => $pen->nama,
'nip' => $pen->nip,
'nik' => $pen->nik,
'unit' => $pen->unit,
'created_at' => $pen->created_at,
'judul' => $pen->penelaah->judul,
'kode_kategori' => $pen->penelaah->kategori->kode_kategori,
'nama_kategori' => $pen->penelaah->kategori->nama_kategori,
'poin_saku' => $pen->penelaah->kategori->poin_saku,
'tahun' => $pen->penelaah->tahun
];
}
}
return response()->json($dataTelaah);
......
......@@ -19,5 +19,5 @@
return $request->user();
});
Route::get('/saku', [ApiSakuController::class, 'index']);
Route::get('/saku/{tahun}', [ApiSakuController::class, 'index']);
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