public function store(Request $request) { $this->validate($request, ['auction_id' => 'required|exists:auctions,id']); $input = $request->all(); $input['user_id'] = Auth::user()->id; $user_watchlist = Watchlist::where('auction_id', $input['auction_id'])->where('user_id', $input['user_id'])->first(); if (is_null($user_watchlist)) { Watchlist::create($input); } return trans('auctions.watchlist.added'); }
public function storewatchlist($auction_id) { if (Watchlist::where('user_id', '=', Auth::user()->User->id)->where('auction_id', '=', $auction_id)->exists()) { // If already in watchlist, go back without adding to db return Redirect::back(); } $watchlist['auction_id'] = $auction_id; $watchlist['user_id'] = Auth::user()->User->id; Watchlist::create($watchlist); return Redirect::back(); }
/** * Store a newly created resource in storage. * * @return \Illuminate\Http\Response */ public function store($id) { Watchlist::create(['user_id' => Auth::user()->id, 'auction_id' => $id]); return redirect('/watchlist'); }