public function getKelasMember($kodeKelas, $kodeGrup)
 {
     $data = array('mahasiswa' => Mhskelas::with('mhs')->where('kodekelas', '=', $kodeKelas)->whereNotExists(function ($query) use($kodeKelas, $kodeGrup) {
         $query->select(DB::raw('nim'))->from('anggota_grup')->whereRaw('mhskelas.nim = anggota_grup.nim')->where('anggota_grup.kodekelas', '=', $kodeKelas)->where('anggota_grup.id_grup', '=', $kodeGrup);
     })->get(), 'kodeKelas' => $kodeKelas, 'kodeGrup' => $kodeGrup);
     return view('frontend.includes.grup-member-add')->with($data);
 }
 public function getData($id, $title, $kode)
 {
     $dateNow = Carbon::now();
     $kelasDosen = Perkuliahan::select('kodekelas')->where('nip', '=', $id)->get()->toArray();
     $data = array('dosen' => DB::table('dosen')->where('nip', $id)->first(), 'dosenProfile' => Dosen::where('nip', '=', Request::segment(3))->first(), 'kelas' => Mhskelas::with(array('mhs', 'perkuliahan', 'mk'))->where('nim', '=', $id)->get(), 'kelasDosen' => Perkuliahan::with(array('mk', 'dosen'))->where('nip', '=', $id)->get(), 'title' => $title, 'listPerkuliahan' => ['' => '-- Pilih kelas --'] + Mhskelas::select('matakuliah.namamk', 'mhskelas.kodekelas')->join('matakuliah', 'mhskelas.kodemk', '=', 'matakuliah.kodemk')->join('mahasiswa', 'mhskelas.nim', '=', 'mahasiswa.nim')->where('mahasiswa.nim', '=', $id)->lists('matakuliah.namamk', 'mhskelas.kodekelas'), 'perkuliahanDosen' => ['' => '-- Pilih kelas --'] + Perkuliahan::select('perkuliahan.kodekelas', 'matakuliah.namamk')->join('matakuliah', 'matakuliah.kodemk', '=', 'perkuliahan.kodemk')->where('perkuliahan.nip', '=', $id)->lists('matakuliah.namamk', 'perkuliahan.kodekelas'), 'grup' => AnggotaGrup::select('grup.nama', 'grup.kodekelas')->join('grup', 'grup.id', '=', 'anggota_grup.id_grup')->where('anggota_grup.nim', '=', $id)->get(), 'post' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('creator', '=', $id)->get(), 'postKelas' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('id_scope', '=', $kode)->get(), 'kelasMember' => Mhskelas::with('mhs')->where('kodekelas', '=', $kode)->get(), 'infokelas' => Perkuliahan::with('mk', 'dosen')->where('kodekelas', '=', $kode)->first(), 'tugasDosen' => Tugas::where('pengumpulan', '>=', $dateNow)->whereIn('kelas', $kelasDosen)->get(), 'pengumumanDosen' => Pengumuman::where('waktuaktif', '>=', $dateNow)->whereIn('kodekelas', $kelasDosen)->get());
     return $data;
 }
 public function getMhsKelas($id)
 {
     $mhskelas = Mhskelas::with('mhs')->where('kodekelas', '=', $id)->get();
     return json_encode($mhskelas);
 }
 public function uploadFile()
 {
     $client = $this->getClient();
     $kelas = Request::input('kelas');
     //Token Expired dan Session masih aktif
     if ($client->isAccessTokenExpired() && Session::has('access_token')) {
         $getToken = User::find(Session::get('user_id'));
         $tempToken = json_decode($getToken->access_token);
         $client->refreshToken($tempToken->refresh_token);
         Session::put('access_token', $client->getAccessToken());
         $getToken->refresh_token = $client->getAccessToken();
         $getToken->save();
         $service = new \Google_Service_Drive($client);
         $parentId = $this->getFolder($service, 'Materi');
         $this->insertFile($service, $parentId);
         $fileId = $this->insertFile($service, $parentId)->getId();
         //Mendapatkan Email Mhs Kelas
         $arrList = Mhskelas::with('mhs')->where('kodekelas', '=', $kelas)->get();
         $temp = array();
         $email = array();
         for ($i = 0; $i < count($arrList); $i++) {
             $temp[$i] = $arrList[$i];
             $email[$i] = $temp[$i]->mhs->email;
         }
         //Share Dokumen
         for ($i = 0; $i < count($email); $i++) {
             $this->sharing($service, $fileId, "user", "reader", $email[$i]);
         }
     }
 }