/** * Display a listing of the resource. * * @return Response */ public function index() { $this->data = array(); $this->data['artikel'] = Artikel::get(); $this->data['news'] = News::get(); return view('home', $this->data); }
public function votedown($id) { $this->first($id); $vote = DB::table('votes')->where('user_id', '=', Auth::user()->id)->where('artikel_id', '=', $id)->first(); $artikel = Artikel::findOrFail($id); if ($vote->algeklikt == false) { $artikel->value--; $vote->down = false; $vote->up = true; $vote->algeklikt = true; } elseif ($vote->down == true && $vote->up == false) { $artikel->value--; $artikel->value--; $vote->down = false; $vote->up = true; } $artikel->save(); DB::table('votes')->where('user_id', '=', Auth::user()->id)->where('artikel_id', '=', $id)->update(['down' => $vote->down, 'up' => $vote->up, 'algeklikt' => $vote->algeklikt]); Session::put('notiftype', 'success'); Session::put('notifmessage', 'You have downvoted "' . $artikel->title . '"'); return back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($jenis, $id) { if ($jenis == "artikel") { $data = Artikel::find($id); $data->delete(); return redirect('/bos/artikel'); } if ($jenis == "kategori") { $data = Kategori::find($id); $data->delete(); return redirect('/bos/kategori'); } }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index(Artikel $artikel, User $user) { $votes = Vote::all(); $artikels = Artikel::with('user.votes')->orderBy('value', 'desc')->get(); return view('home')->with('artikels', $artikels)->with('votes', $votes); }
public function update(Artikel $artikel, Request $request) { $artikel->fill($request->input())->save(); $artikel->save(); return redirect("artikels"); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id_kategori, $id_artikel) { if (Request::isMethod('get')) { $this->data = array(); $this->data['artikel'] = Artikel::find($id_artikel); return View::make('admin.article.delete', $this->data); } else { if (Request::isMethod('post')) { $data = Input::all(); Artikel::where('id', $id_artikel)->delete(); return redirect('admin/artikel/' . $id_kategori); } } }
public function destroy($id) { $vote = DB::table('votes')->where('artikel_id', $id); $vote->delete(); $comment = DB::table('comments')->where('artikel_id', $id); $comment->delete(); Session::put('notiftype', 'success'); Session::put('notifmessage', 'Article deleted successfully'); Artikel::find($id)->delete(); return redirect('/home'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $comment = Comment::findOrFail($id); $this->validate($request, ['comment' => 'required|max:255']); $data = $request->only('comment'); $comment->update($data); $artikel = Artikel::findOrFail($request->artikel_id); $comments = Comment::with('user')->where('artikel_id', '=', $id)->get(); Session::put('notiftype', 'success'); Session::put('notifmessage', 'comment edited succesfully.'); return back(); }