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 addPhoto($id) { $xhr = $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; $file = Request::file('file'); $extension = $file->getClientOriginalExtension(); $photoName = $file->getFilename() . '.' . $extension; //Storage::put($file->getFilename() . '.' . $extension, File::get($file)); $uploadPath = 'assets/upload'; $file->move($uploadPath, $photoName); if (Auth::user()->role == "mahasiswa") { $mahasiswa = Mahasiswa::where("nim", "=", $id)->first(); $mahasiswa->foto = $photoName; $mahasiswa->save(); } else { $dosen = Dosen::where('nip', '=', $id)->first(); $dosen->foto = $photoName; $dosen->save(); } if ($xhr) { echo $photoName; } }
public function getPost($kode, $kodeGrup) { if ($kodeGrup == 0) { $segmentKelas = "true"; $segmentGrup = "false"; } elseif ($kodeGrup > 0) { $segmentKelas = "false"; $segmentGrup = "true"; } else { $segmentKelas = "false"; $segmentGrup = "false"; } $id = Session::get('user'); if (Auth::user()->role == "mahasiswa") { $foto = Mahasiswa::where('nim', '=', $id)->first(); //Mendapatkan Array Kelas $kelasTmp = Mhskelas::select('kodekelas')->where('nim', '=', $id)->get(); for ($i = 0; $i < count($kelasTmp); $i++) { $kelas[$i] = $kelasTmp[$i]['kodekelas']; } //Mendapatkan Array Grup $grupTmp = AnggotaGrup::select('id_grup')->where('nim', '=', $id)->get(); for ($i = 0; $i < count($grupTmp); $i++) { $grup[$i] = $grupTmp[$i]['id_grup']; } $scope = array_merge($kelas, $grup); } else { $foto = Dosen::where('nip', '=', $id)->first(); $kelasTmp = Perkuliahan::select('kodekelas')->where('nip', '=', $id)->get(); for ($i = 0; $i < count($kelasTmp); $i++) { $scope[$i] = $kelasTmp[$i]['kodekelas']; } } $data = array('post' => Post::with(array('komentar', 'mhs', 'dosen', 'perkuliahan'))->whereIn('id_scope', $scope)->orderBy('id', 'desc')->take(10)->get(), 'postKelas' => Post::with(array('komentar', 'mhs', 'dosen', 'perkuliahan', 'grup'))->where('id_scope', '=', $kode)->where('scope', '=', 'kelas')->orderBy('id', 'desc')->get(), 'postGrup' => Post::with(array('komentar', 'mhs', 'grup', 'perkuliahan'))->where('id_scope', '=', $kodeGrup)->where('scope', '=', 'grup')->orderBy('id', 'desc')->get(), 'foto' => $foto, 'segmentKelas' => $segmentKelas, 'segmentGrup' => $segmentGrup); return view('frontend.includes.posts')->with($data); }
| */ Route::get('/', function () { return view('welcome'); }); //RELASI ELOQUENT Route::get('relasi-1', function () { $mahasiswa = Mahasiswa::where('nim', '=', '1103120133')->first(); return $mahasiswa->wali->nama; }); Route::get('relasi-2', function () { $mahasiswa = Mahasiswa::where('nim', '=', '1103124321')->first(); return $mahasiswa->dosen->nama; }); Route::get('relasi-3', function () { $dosen = Dosen::where('nama', '=', 'Fazma Arif')->first(); foreach ($dosen->mahasiswa as $temp) { echo '<li> Nama : ' . $temp->nama . ' <strong> (' . $temp->nim . ') </strong></li>'; } }); Route::get('relasi-4', function () { $ganin = Mahasiswa::where('nama', '=', 'Ganine Vinanda')->first(); foreach ($ganin->hobi as $temp) { echo '<li>' . $temp->hobi . '</li>'; } }); Route::get('relasi-5', function () { $ngoding = Hobi::where('hobi', '=', 'Ngoding')->first(); foreach ($ngoding->mahasiswa as $temp) { echo '<li> Nama : ' . $temp->nama . ' <strong>' . $temp->nim . '</strong></li>'; }
public function getUser($folder, $kelas, $grup, $tugasId) { $client = $this->getClient(); $getToken = User::find(Session::get('user_id')); //Token Expired dan Session masih aktif if ($client->isAccessTokenExpired() && $getToken->access_token != "") { $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); $googlePlus = new \Google_Service_Plus($client); $file = new \Google_Service_Drive_DriveFile(); $userProfile = $googlePlus->people->get('me'); $emails = $userProfile->getEmails(); $photo = $userProfile->getImage(); $userId = $userProfile->getId(); /*$value = array("*****@*****.**","*****@*****.**"); for ($i=0; $i < 2; $i++) { $this->sharing($service,$this->getParent($service)[0]->id,"user","reader",$value[$i]); } */ if (count($this->getParent($service)) == 0) { $this->makeFolder($file, $service, "Collaborative Learning", null); $this->makeFolder($file, $service, "Materi", $this->getParent($service)[0]->id); $this->makeFolder($file, $service, "Tugas", $this->getParent($service)[0]->id); } $result = $this->getFolderItem($service, $this->getFolder($service, $folder), $kelas, $grup, $tugasId); $data = array('email' => $emails[0]->value, 'photo' => $photo->url, 'userId' => $userId, 'result' => $result, 'title' => 'test'); //User belum melakukan autentikasi } else { if (!Session::has('access_token') && $getToken->access_token == "") { $id = Session::get('user'); if (Auth::user()->role == "mahasiswa") { $pengguna = Mahasiswa::where('nim', '=', $id)->first(); } else { $pengguna = Dosen::where('nip', '=', $id)->first(); } $data = array('title' => 'test', 'user' => $pengguna->email); //Session tidak aktif tapi user telah melakukan autentikasi } else { if (!Session::has('access_token') && $client->getAccessToken()) { Session::put('access_token', $client->getAccessToken()); $data = array('title' => 'test'); } else { $client->setAccessToken(Session::get('access_token')); $data = array('title' => 'test'); } } } return view('frontend.includes.storage-content')->with($data); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $data = array('dosen' => Dosen::where('status', '=', 1)->get(), 'title' => 'dosen'); return view('backend.pages.backend-show-dosen')->with($data); }
public function index() { $data = array('title' => "dashboard", 'dosen' => count(Dosen::where('status', '=', 1)->get()), 'mahasiswa' => count(Mahasiswa::where('status', '=', 1)->get()), 'matakuliah' => count(Matakuliah::where('status', '=', 1)->get()), 'perkuliahan' => count(Perkuliahan::where('status', '=', 1)->get()), 'userMhs' => User::with('mhs')->where('role', '=', 'mahasiswa')->get(), 'userDosen' => User::with('dosen')->where('role', '=', 'dosen')->get()); return view('backend.pages.backend-home')->with($data); }