vitareinforce

simpan presensi

Nov 29th, 2020 (edited)
637
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function store(Request $request) {
  2.     // ambil data di section pertama
  3.     $jenis_kehadiran = $request->jenis_kehadiran;
  4.     $karyawan_id = $request->karyawan_id;
  5.     $karyawan = Karyawan::find($request_karyawan_id);
  6.     $group_id = $karyawan->group_id;
  7.     $jadwal_id = $karyawan->jadwal_id;
  8.     $setting_presensi = SettingPresensi::find(1);
  9.     $setting_poin_presensi = SettingPoinPresensi::find(1);
  10.  
  11.  
  12.     // yang ini tolong bantu cari gmn cara gabungin date dan time
  13.     $tanggal_dan_jam_mulai = $request->tanggal + $request->jam_mulai;
  14.     $tanggal_dan_jam_istirahat_mulai = $request->tanggal + $request->istirahat_mulai;
  15.     $tanggal_dan_jam_istirahat_selesai = $request->tanggal + $request->istirahat_selesai;
  16.     $tanggal_dan_jam_pulang = $request->tanggal + $request->jam_pulang;
  17.  
  18.     // buat 4 data input kehadiran
  19.     $presensi_mulai = array(
  20.         'karyawan_id' => $karyawan_id,
  21.         'group_id' => $group_id,
  22.         'jadwal_id' => $jadwal_id,
  23.         'setting_presensi_id' => $setting_presensi->id,
  24.         'tanggal_dan_waktu_tap' => $tanggal_dan_jam_mulai,
  25.         'poin' => $setting_poin_presensi->poin,
  26.         'status' => 'Hadir'
  27.     );
  28.     $presensi_istirahat_mulai = array(
  29.         'karyawan_id' => $karyawan_id,
  30.         'group_id' => $group_id,
  31.         'jadwal_id' => $jadwal_id,
  32.         'setting_presensi_id' => $setting_presensi->id,
  33.         'tanggal_dan_waktu_tap' => $tanggal_dan_jam_istirahat_mulai,
  34.         'poin' => $setting_poin_presensi ->poin,
  35.         'status' => 'Hadir'
  36.     );
  37.     $presensi_istirahat_selesai = array(
  38.         'karyawan_id' => $karyawan_id,
  39.         'group_id' => $group_id,
  40.         'jadwal_id' => $jadwal_id,
  41.         'setting_presensi_id' => $setting_presensi->id,
  42.         'tanggal_dan_waktu_tap' => $tanggal_dan_jam_istirahat_selesai,
  43.         'poin' => $setting_poin_presensi->poin,
  44.         'status' => 'Hadir'
  45.     );
  46.     $presensi_pulang = array(
  47.         'karyawan_id' => $karyawan_id,
  48.         'group_id' => $group_id,
  49.         'jadwal_id' => $jadwal_id,
  50.         'setting_presensi_id' => $setting_presensi->id,
  51.         'tanggal_dan_waktu_tap' => $tanggal_dan_jam_pulang,
  52.         'poin' => $setting_poin_presensi->poin,
  53.         'status' => 'Hadir'
  54.     );
  55.  
  56.     // Simpan
  57.     Presensi::create($presensi_mulai);
  58.     Presensi::create($presensi_istirahat_mulai);
  59.     Presensi::create($presensi_istirahat_selesai);
  60.     Presensi::create($presensi_pulang);
  61.  
  62. }
RAW Paste Data