vitareinforce

api upah group

Feb 2nd, 2021 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public function apiHitungUpahGroup($id)
  2. {
  3. $periodegaji = PeriodeGaji::find($id);
  4. $periodemulai = $periodegaji->tanggal_mulai_periode;
  5. $periodeselesai = $periodegaji->tanggal_selesai_periode;
  6.  
  7. $group = Group::with('karyawans.gajis')->get();
  8. for($g = 0; $g < count($group); $g++) {
  9. $poin = 0;
  10. $upah = 0;
  11. for($k = 0; $k < count($group[$g]->karyawans); $k++) {
  12. if(isset($group[$g]->karyawans[$k]->gajis)) {
  13. for($gj = 0; $gj < count($group[$g]->karyawans[$k]->gajis); $gj++) {
  14. if($group[$g]->karyawans[$k]->gajis[$gj]->periodegaji_id == $id) {
  15. $poin = $poin + $group[$g]->karyawans[$k]->gajis[$gj]->poin;
  16. $upah = $upah + $group[$g]->karyawans[$k]->gajis[$gj]->total;
  17. }
  18. }
  19. }
  20. }
  21. $group[$g]->setAttribute('total_karyawan', count($group[$g]->karyawans));
  22. $group[$g]->setAttribute('total_poin', $poin);
  23. $group[$g]->setAttribute('total_upah_group', $upah);
  24. }
  25.  
  26. return Response::json($group);
  27. }
Add Comment
Please, Sign In to add comment