public function getData($id, $title, $kodeKelas, $kodeGrup) { $dateNow = Carbon::now(); $kelasDosen = Perkuliahan::select('kodekelas')->where('nip', '=', $id)->get()->toArray(); $kelasMhs = Mhskelas::select('kodekelas')->where('nim', '=', $id)->get()->toArray(); $data = array('mahasiswaProfile' => Mahasiswa::with('dosenWali')->where('nim', '=', Request::segment(3))->first(), 'mahasiswa' => Mahasiswa::where('nim', '=', $id)->first(), 'dosenwali' => ['' => '-- Pilih dosen --'] + Dosen::lists('nama', 'nip'), 'kelas' => Mhskelas::with(array('mhs', 'perkuliahan', 'mk'))->where('nim', '=', $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'), 'grup' => AnggotaGrup::select('grup.nama', 'grup.kodekelas', 'grup.id')->join('grup', 'grup.id', '=', 'anggota_grup.id_grup')->where('anggota_grup.nim', '=', $id)->get(), 'kelasMember' => Mhskelas::with('mhs')->where('kodekelas', '=', $kodeKelas)->get(), 'infokelas' => Perkuliahan::with('mk', 'dosen')->where('kodekelas', '=', $kodeKelas)->first(), 'infoGrup' => Grup::with('mk', 'mhs')->where('id', '=', $kodeGrup)->first(), 'grupMember' => AnggotaGrup::with('mhs')->where('id_grup', '=', $kodeGrup)->get(), 'inviteNotifCount' => Notifikasi::with('mhs')->where('recepient', '=', $id)->get(), 'tugasDosen' => Tugas::where('pengumpulan', '>=', $dateNow)->whereIn('kelas', $kelasDosen)->get(), 'tugasMhs' => Tugas::where('pengumpulan', '>=', $dateNow)->whereIn('kelas', $kelasMhs)->get(), 'pengumumanDosen' => Pengumuman::where('waktuaktif', '>=', $dateNow)->whereIn('kodekelas', $kelasDosen)->get(), 'pengumumanMhs' => Pengumuman::where('waktuaktif', '>=', $dateNow)->whereIn('kodekelas', $kelasMhs)->get()); return $data; }
public function makeFile() { $client = $this->getClient(); //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); $file = new \Google_Service_Drive_DriveFile(); $title = Request::input('judul'); $mimetype = Request::input('mimetype'); $kelas = Request::input('kelas'); $grup = Request::input('grup'); $parentId = $this->getFolder($service, 'Tugas'); $file->setTitle($kelas . '_' . $grup . '_' . $title); $file->setMimeType($mimetype); if ($parentId != null) { $parent = new \Google_Service_Drive_ParentReference(); $parent->setId($parentId); $file->setParents(array($parent)); } $createdFile = $service->files->insert($file); $fileId = $createdFile->getId(); //Mendapatkan Email Anggota Grup $arrList = AnggotaGrup::with('mhs')->where('id_grup', '=', $grup)->get(); $temp = array(); $email = array(); for ($i = 0; $i < count($arrList); $i++) { $temp[$i] = $arrList[$i]; $email[$i] = $temp[$i]->mhs->email; } //dd($email); //Share Dokumen for ($i = 0; $i < count($email); $i++) { $this->sharing($service, $fileId, "user", "writer", $email[$i]); } return "sukses"; } }