public function quote($id = null) { if (!is_numeric($id)) { return redirect('/notFound'); } $Quote = Quote::find($id); if (null == $Quote) { return redirect('/notFound'); } return view('welcome')->with('Quotes', [$Quote])->with('pageTitle', trans('app.quote'))->with('noPaginate', true); }
public function rate(Request $request) { $ratings = $request->session()->get('ratings', []); $rating = $request->input('rating'); $id = $request->input('id'); $quote = Models\Quote::find($id); if (!in_array($id, $ratings)) { if ($rating > 0) { $quote->rating += 1; } else { $quote->rating -= 1; } $quote->save(); $ratings[] = $id; $request->session()->put('ratings', $ratings); } return response()->json(['rating' => $quote->rating]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $quote = Quote::find($id); $quote->delete(); return back(); }