public function postTargetPricePage($id, Request $request) { $alreadyUserPrice = UserPrice::where('user_id', Auth::user()->id)->where('product_id', $id)->first(); if ($alreadyUserPrice) { $alreadyUserPrice->target_price = $request->get('target_price'); $alreadyUserPrice->save(); } else { $userPrice = new UserPrice(); $userPrice->user_id = Auth::user()->id; $userPrice->product_id = $id; $userPrice->target_price = $request->get('target_price'); $userPrice->save(); } Session::flash('notify', 'We will notify you as soon as the product drops its reach up to your target price'); return Redirect::route('dashboard'); }