/** * Display a listing of the resource. * * @return Response */ public function index() { if (\Auth::user()->idpegawai == 1) { $cuti = \App\Cuti::where('status', 'Pending')->count(); $lembur = \App\Lembur::where('status', 'Pending')->count(); } else { $cuti = \App\Cuti::where('tglawal', '>', Carbon::now())->where('status', 'Accepted')->where('pegawai_id', \Auth::user()->idpegawai)->count(); $lembur = \App\Lembur::where('tgllembur', '>', Carbon::now()->subWeek())->where('tgllembur', '<', Carbon::now())->where('status', 'Accepted')->where('pegawai_id', \Auth::user()->idpegawai)->count(); $training = \Auth::user()->training()->future()->count(); } return view('pages/dashboard/dashboard', compact('cuti', 'lembur', 'training')); }
public function decline($idcuti) { $cuti = Cuti::findOrFail($idcuti); $cuti->status = 'Declined'; $cuti->save(); flash()->overlay('Cuti telah ditolak!'); return redirect('cuti'); }