/** * Store a newly created resource in storage. * * @return Response */ public function store() { $grup = new Grup(); $grup->nama = Request::input('nama'); $grup->kodekelas = Request::input('kelas'); $grup->nim = Session::get('user'); $grup->save(); $last = Grup::orderBy('created_at', 'desc')->first(); $member = new AnggotaGrup(); $member->id_grup = $last->id; $member->nim = Request::input('nim'); $member->kodekelas = Request::input('kelas'); $member->save(); }
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 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); }
public function showGrup() { $id = Session::get('user'); $data = array('grup' => AnggotaGrup::select('grup.nama', 'grup.kodekelas', 'grup.id')->join('grup', 'grup.id', '=', 'anggota_grup.id_grup')->where('anggota_grup.nim', '=', $id)->get()); return view('frontend.includes.grup-list')->with($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"; } }