public function getData() { if (\Auth::user()->idpegawai == 1) { $training = Training::oldest('tgltraining')->get(); } else { $training = Training::select('*')->join('pegawai_training', 'training.idtraining', '=', 'pegawai_training.training_id')->where('pegawai_training.pegawai_id', '=', \Auth::user()->idpegawai)->get(); } //dd($training); return Datatables::of($training)->editColumn('tgltraining', function ($training) { return $training->tgltraining ? with(new Carbon($training->tgltraining))->format('d-m-Y') : ''; })->addColumn('action', function ($training) { return view('pages.training.action', compact('training'))->render(); })->make(true); }