Skip to content

Commit

Permalink
Update StafApiController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdianS18 committed Nov 18, 2024
1 parent 128bf52 commit cbd7135
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions app/Http/Controllers/Api/StafApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ public function index(User $user)
$approved = $this->studentRepair->count_approved('1');
$process = $this->studentRepair->count_approved('0');
$not_process = $this->studentRepair->count_approved(null);
$employeeJournals = $this->employeeJournal->getEmployee($user->id, 'take_2');

return response()->json(['status' => 'success', 'message' => "Berhasil mengambil data",'code' => 200, 'data' => [
'approved' => $approved,
'process' => $process,
'not_process' => $not_process,
'journals' => EmployeeJournalResource::collection($employeeJournals),
]], 200);
} catch (\Throwable $th) {
return response()->json(['status' => 'success', 'message' => "Data Kosong",'code' => 400], 400);
Expand All @@ -83,9 +81,23 @@ public function history_journals(User $user)
try {
$employeeJournals = $this->employeeJournal->getEmployee($user->id, 'get');

return response()->json(['status' => 'success', 'message' => "Berhasil mengambil data",'code' => 200, 'data' => [
'journals' => EmployeeJournalResource::collection($employeeJournals),
]], 200);
if ($employeeJournals->where('created_at', '>=', Carbon::today())->isEmpty()) {
return response()->json([
'journal_message' => 'Hari ini anda belum mengisi jurnal!',
'status' => 'success',
'message' => "Berhasil mengambil data",
'code' => 200,
'data' => [ 'journals' => EmployeeJournalResource::collection($employeeJournals),]
], 200);
} else {
return response()->json([
'status' => 'success',
'message' => "Berhasil mengambil data",
'code' => 200,
'data' => [ 'journals' => EmployeeJournalResource::collection($employeeJournals),]
], 200);
}

} catch (\Throwable $th) {
return response()->json(['status' => 'success', 'message' => "Data Kosong",'code' => 400], 400);
}
Expand Down

0 comments on commit cbd7135

Please sign in to comment.