예제 #1
0
 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);
 }
예제 #2
0
 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]);
 }
예제 #3
0
 /**
  * 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();
 }