/**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $auctions = Auction::get();
     $mytime = Carbon::now()->addDays(2);
     $timenow = $mytime->toDateTimeString();
     foreach ($auctions as $auction) {
         if ($auction->enddate < $timenow) {
             $auction->FK_status_id = '4';
             $auction->save();
             $lostbidders = Bidder::where('FK_auction_id', '=', $auction->id)->distinct()->with('user')->get();
             //distinct voor duplicate receivers
             //mail sturen naar verliezende
             foreach ($lostbidders as $bidder) {
                 //mail sturen naar verliezende bidders
                 Mail::send('email.lostauction', array('descriptionEnglish' => $auction->descriptionEnglish, 'descriptionDutch' => $auction->descriptionDutch, 'title' => $auction->title), function ($message) {
                     $message->from('*****@*****.**');
                     $message->to($bidder->user->email, 'Admin')->subject('You have lost an auction on Landoretti');
                 });
             }
         }
     }
 }
 public function buyout($id)
 {
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     $auction = Auction::find($id);
     $lostbidders = Bidder::where('FK_auction_id', '=', $auction->id)->distinct()->with('user')->get();
     //distinct voor duplicate receivers
     if (Auth::user()->id == $auction->FK_user_id) {
         $warning = 'This is your own item!';
         return redirect()->back()->with('warning', $warning);
     }
     $auction->FK_status_id = '5';
     //sold
     $auction->save();
     //mail sturen naar andere bieders
     foreach ($lostbidders as $bidder) {
         if ($bidder->FK_user_id != Auth::user()->id) {
             //mail sturen naar verliezende bidders
             Mail::send('email.lostauction', array('descriptionEnglish' => $auction->descriptionEnglish, 'descriptionDutch' => $auction->descriptionDutch, 'title' => $auction->title), function ($message) {
                 $message->from('*****@*****.**');
                 $message->to($bidder->user->email, 'Admin')->subject('You have lost an auction on Landoretti');
             });
         }
     }
     return View::make('buynow')->with('newestAuction', $newestAuction);
 }
示例#3
0
 public function bid(Request $request)
 {
     $this->validate($request, ['id' => 'required', 'prev' => 'required', 'bid' => 'required|greater_than_field:prev']);
     $auction = Auction::findOrFail($request->id);
     $auction->price = $request->bid;
     $auction->save();
     $user = Auth::user();
     $bidder = new Bidder();
     $bidder->user()->save($user);
     $bidder->auction()->associate($auction);
     $bidder->price = $request->bid;
     $bidder->save();
     return redirect('/art');
 }
 public function myBids()
 {
     $bids = Bidder::where('FK_user_id', '=', Auth::user()->id)->with('auction')->orderBy('bidAmount', 'desc')->get();
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     return view('my-bids')->with('bids', $bids)->with('newestAuction', $newestAuction);
 }