/** * Run the database seeds. * * @return void */ public function run() { DB::table('bids')->delete(); $auctions = Auction::get(); foreach ($auctions as $auction) { $random_user = User::orderByRaw("RAND()")->first(); if (rand(0, 5) == 0) { Bid::create(['user_id' => $random_user->id, 'auction_id' => $auction->id, 'price' => $auction->min_price + 999]); } } }
/** * 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'); }); } } } }