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 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 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);
 }