/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store($id) { $auction = Auction::findOrFail($id); $watcher = Auth::user(); $watchlist = Watchlist::firstOrNew(array('user_id' => $watcher->id, 'auction_id' => $auction->id)); $watchlist->save(); return Redirect::route('watchlist.my'); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $randomAuctions = Auction::getRandomAuctions(4); $auction = Auction::findOrFail($id); $bids = $auction->bids(); // return $bids; return view('detail', compact('auction', 'bids', 'randomAuctions')); }
protected function bid($bidder_id, $auction_id) { $bidder = User::findOrFail($bidder_id); $auction = Auction::findOrFail($auction_id); $users = DB::table('users')->select(DB::raw('users.id'))->join('bids', 'users.id', '=', 'bids.bidder_id')->where('bids.auction_id', $auction_id)->where('users.id', '!=', $bidder_id)->get(); // Confirmation message for bidder $message = ['title' => 'Your bid has been placed', 'message' => 'You have successfully placed a bid on <b>' . $auction->title . '</b>', 'opened' => null, 'archived' => 0, 'user_id' => $bidder_id, 'sender_id' => 1]; self::create($message); // Heads up to other bidders foreach ($users as $user) { $outbid = ['title' => 'Someone else bid on <b>' . $auction->title . '</b>', 'message' => 'Someone else has just placed a bid on <b>' . $auction->title . '</b><br>Click <a href="auction/' . $auction->slug . '">here</a> to go to the auction.', 'opened' => null, 'archived' => 0, 'user_id' => $user->id, 'sender_id' => 1]; self::create($outbid); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function buy($id) { $auction = Auction::findOrFail($id); $user = Auth::user(); $user->auctionsbuyer()->save($auction); $auction->status = "sold"; Mail::send('emails.sorry', ['user' => $user], function ($m) use($user) { $m->from('*****@*****.**', 'Landoretti'); $m->to($user->email, $user->name)->subject("Sorry, uw bieding is door iemand overgekocht"); }); }
public function delete($lang, $id) { $auction = Auction::findOrFail($id); if ($auction->seller_id == Auth::user()->id) { $auction->state = 'expired'; $auction->save(); Message::auctionDeleted($id); Session::flash('flash_message', trans('auctions.delete.success')); return redirect()->back(); } return redirect('/'); }
public static function solveProblem($id) { $auction = Auction::findOrFail($id); //assume $id exist; $solver_url = "http://54.68.184.173/solve?url="; $base_domain = "mylazyjoker.com:83/"; $action = "api/auction/problem/" . $id; $whole_url = $solver_url . $base_domain . $action; $client = new Client(); $res = $client->request('Get', $whole_url); $result = $res->getBody(); $jsonObject = json_decode($result); $content = trim($jsonObject->content); $winner = []; $wining_bid = []; $split = explode(' ', $content); for ($x = 0; $x < count($split); $x = $x + 2) { array_push($winner, $split[$x]); array_push($wining_bid, $split[$x + 1]); } $data = ['winner' => $winner, 'winning_bid' => $wining_bid]; return response()->json($data); }