public function actionCreate(Requests\CreateRatingRequest $request) { $rating = new Rating($request->all()); Auth::user()->ratings()->save($rating); \Session::flash('flash_message', 'You have successfully created a rating.'); return redirect('/ratings/' . $rating->id); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CreateRatingRequest $request, $id) { $restaurant = Restaurant::findOrFail($id); $rating = new Rating(); $rating->fill($request->input()); $rating->restaurant()->associate($restaurant); $rating->save(); return $restaurant; }
public function storeRating($id, CreateRatingRequest $request) { $input = $request->all(); if ($input['rating'] == null) { flash()->error("You must choose a value in order to rate this series."); return \Redirect::back(); } $newrating = new Rating(); $newrating->rating = $input['rating']; $newrating->userId = Auth::id(); $newrating->seriesId = $input['sId']; //we already know that the "requester" hasn't rated this serie yet addRating($newrating); flash()->success("Your rating has been stored successfully."); return \Redirect::back(); }