Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sipeka
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Siti Aisah
sipeka
Commits
47aac7d8
Commit
47aac7d8
authored
May 22, 2024
by
Triyah Fatmawati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API SAKU
parent
20f6a56a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
0 deletions
+105
-0
app/Http/Controllers/Api/ApiSakuController.php
+85
-0
app/Models/Admin/MsKategori.php
+4
-0
app/Models/Admin/Penelaah.php
+4
-0
app/Models/Admin/Pengajuan.php
+8
-0
routes/api.php
+4
-0
No files found.
app/Http/Controllers/Api/ApiSakuController.php
0 → 100644
View file @
47aac7d8
<?php
namespace
App\Http\Controllers\Api
;
use
App\Http\Controllers\Controller
;
use
App\Models\Admin\Penelaah
;
use
App\Models\Admin\Pengajuan
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
class
ApiSakuController
extends
Controller
{
public
function
index
(){
$penelaah
=
Penelaah
::
query
()
->
with
(
'penelaah'
)
// ->where('created_at', '<', '2024-05-20')
->
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
,
'updated_at'
=>
$pen
->
updated_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
);
}
public
function
saku1
()
{
$totalPoin
=
0
;
$jmlTelaah
=
Penelaah
::
query
()
->
select
(
'nip'
,
DB
::
raw
(
'COUNT(nip) as jumlah'
))
->
groupBy
(
'nip'
)
->
where
(
'created_at'
,
'<'
,
'2024-05-20'
)
->
get
();
foreach
(
$jmlTelaah
as
$key
=>
$telaah
)
{
$penelaah
=
Penelaah
::
query
()
->
with
(
'penelaah'
)
->
where
(
'nip'
,
$telaah
->
nip
)
->
where
(
'created_at'
,
'<'
,
'2024-05-20'
)
->
get
();
foreach
(
$penelaah
as
$keys
=>
$pen
)
{
$totalPoin
=
$totalPoin
+
$pen
->
penelaah
->
kategori
->
poin_saku
;
$dataPenelaah
[
$telaah
->
nip
]
=
[
'nama'
=>
$pen
->
nama
,
'nik'
=>
$pen
->
nik
,
'nip'
=>
$pen
->
nip
,
'unit'
=>
$pen
->
unit
,
'jumlah'
=>
$telaah
->
jumlah
,
];
$dataTelaah
[
$keys
]
=
[
'id_pengajuan_epk'
=>
$pen
->
penelaah
->
id_pengajuan
,
'judul'
=>
$pen
->
penelaah
->
judul
,
'peneliti'
=>
$pen
->
penelaah
->
peneliti
,
'klasifikasi'
=>
$pen
->
penelaah
->
klasifikasi
,
'file_ec'
=>
$pen
->
penelaah
->
file_ec
,
'no_sk'
=>
$pen
->
penelaah
->
no_sk
,
'kode_kategori'
=>
$pen
->
penelaah
->
kategori
->
kode_kategori
,
'nama_kategori'
=>
$pen
->
penelaah
->
kategori
->
nama_kategori
,
'poin_saku'
=>
$pen
->
penelaah
->
kategori
->
poin_saku
,
];
$dataPenelaah
[
$telaah
->
nip
][
'telaah'
]
=
$dataTelaah
;
$dataPenelaah
[
$telaah
->
nip
][
'totalPoin'
]
=
$totalPoin
;
}
}
return
response
()
->
json
(
$dataPenelaah
);
}
}
app/Models/Admin/MsKategori.php
View file @
47aac7d8
...
...
@@ -22,4 +22,8 @@ class MsKategori extends Model
'poin_saku'
,
'status'
];
public
function
rKategori
(){
return
$this
->
belongsToMany
(
Pengajuan
::
class
,
'id'
,
'id_kategori'
);
}
}
app/Models/Admin/Penelaah.php
View file @
47aac7d8
...
...
@@ -23,4 +23,8 @@ class Penelaah extends Model
'nip'
,
'unit'
];
public
function
penelaah
(){
return
$this
->
belongsTo
(
Pengajuan
::
class
,
'id_pengajuan'
,
'id'
)
->
with
(
'kategori'
);
}
}
app/Models/Admin/Pengajuan.php
View file @
47aac7d8
...
...
@@ -26,4 +26,12 @@ class Pengajuan extends Model
'file_ec'
,
'no_sk'
];
public
function
rPenelaah
()
{
return
$this
->
hasOne
(
Penelaah
::
class
,
'id_pengajuan'
,
'id'
);
}
public
function
kategori
(){
return
$this
->
hasOne
(
MsKategori
::
class
,
'id'
,
'id_kategori'
);
}
}
routes/api.php
View file @
47aac7d8
<?php
use
App\Http\Controllers\Api\ApiSakuController
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Route
;
...
...
@@ -17,3 +18,6 @@
Route
::
middleware
(
'auth:sanctum'
)
->
get
(
'/user'
,
function
(
Request
$request
)
{
return
$request
->
user
();
});
Route
::
get
(
'/saku'
,
[
ApiSakuController
::
class
,
'index'
]);
Route
::
get
(
'/saku1'
,
[
ApiSakuController
::
class
,
'saku1'
]);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment