/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function edit($id) { $kelas = Kelas::findOrFail($id); if ($kelas->dosen_id !== Auth::user()->id) { return redirect('kelas'); } $account = Auth::user()->userable; $makuls = MataKuliah::where('prodi_id', $account->prodi_id)->lists('nama', 'id')->toArray(); return view('kelas.edit', compact('kelas', 'makuls')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request) { foreach ($request->vote as $id) { $mk = MataKuliah::findOrFail($id); $mk->peminat += 1; $mk->save(); } $account = Auth::user()->userable; $account->voted = true; $account->save(); return redirect('vote'); }
/** * Run the database seeds. */ public function run() { Model::unguard(); $if = ProgramStudi::create(['nama' => 'S1 Teknik Informatika', 'deskripsi' => 'Informatika adalah.....']); $ik = ProgramStudi::create(['nama' => 'S1 Ilmu Komputasi', 'deskripsi' => 'IK adalah.....']); $admin = Admin::create(); $user = User::create(['nama' => 'feber', 'username' => 'feber', 'password' => bcrypt('feber'), 'userable_id' => $admin->id, 'userable_type' => User::TYPE_ADMIN]); $dosen = Dosen::create(['nip' => '053', 'prodi_id' => $if->id]); $user = User::create(['nama' => 'mahar', 'username' => 'mahar', 'password' => bcrypt('mahar'), 'userable_id' => $dosen->id, 'userable_type' => User::TYPE_DOSEN]); $dosen = Dosen::create(['nip' => '054', 'prodi_id' => $ik->id]); $user = User::create(['nama' => 'sendy', 'username' => 'sendy', 'password' => bcrypt('sendy'), 'userable_id' => $dosen->id, 'userable_type' => User::TYPE_DOSEN]); $mahasiswa = Mahasiswa::create(['nim' => '1103', 'prodi_id' => $if->id]); $user = User::create(['nama' => 'dimas', 'username' => 'dimas', 'password' => bcrypt('dimas'), 'userable_id' => $mahasiswa->id, 'userable_type' => User::TYPE_MAHASISWA]); $mahasiswa = Mahasiswa::create(['nim' => '1107', 'prodi_id' => $ik->id]); $user = User::create(['nama' => 'ali', 'username' => 'ali', 'password' => bcrypt('ali'), 'userable_id' => $mahasiswa->id, 'userable_type' => User::TYPE_MAHASISWA]); MataKuliah::create(['nama' => 'Desain Analisis Algoritma', 'kode' => 'CSG1xx', 'deskripsi' => 'Main algoritma...', 'prodi_id' => $if->id]); MataKuliah::create(['nama' => 'Algoritma Struktur Data', 'kode' => 'CSG2xx', 'deskripsi' => 'ASD...', 'prodi_id' => $if->id]); MataKuliah::create(['nama' => 'Data Mining', 'kode' => 'CSH1xx', 'deskripsi' => 'Main data...', 'prodi_id' => $ik->id]); Model::reguard(); }
/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function destroy($id) { MataKuliah::destroy($id); return redirect('makul'); }