Beispiel #1
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         Mail::raw('Hi Dries!', function ($message) {
             $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
             $message->to('*****@*****.**')->subject('Test mail!');
         });
     })->daily();
     $schedule->call(function () {
         $expiringAuctions = Auction::getExpiringAuctions();
         foreach ($expiringAuctions as $auction) {
             $bidders = Bid::getBiddersWithId($auction->id);
             $highest = Bid::getHighestBidWithId($auction->id);
             $auction->buyer_id = $highest->id;
             $auction->save();
             foreach ($bidders as $bidWithBidder) {
                 $bidder = $bidWithBidder->user;
                 if ($bidder->id = $highest->id) {
                     Mail::raw('Auction ' . $auction->title . ' ended, you are the highest bidder!', function ($message) use($bidder) {
                         $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
                         $message->to($bidder->email)->subject('You are the highest bidder.');
                     });
                 } else {
                     Mail::raw('Auction ' . $auction->title . ' ended, you did not give the highest bid!', function ($message) use($bidder) {
                         $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
                         $message->to($bidder->email)->subject("Auction ended, you didn't get it.");
                     });
                 }
             }
         }
     })->daily();
 }
 public function search(Request $request)
 {
     $input = $request->all();
     $query = $input['search'];
     $auctions = Auction::where('title', 'LIKE', '%' . $query . '%')->where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->get();
     return view('search')->with('auctions', $auctions)->with('query', $query);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $auctions = Auction::where('active', '=', true)->get();
     foreach ($auctions as $key => $auction) {
         if ($auction->end_date < Carbon::now() && $auction->active == true) {
             // auction end
             $auction->active = false;
             $auction->save();
             // highest bidder mail congrats
             $highestbid = Bid::where('auction_id', '=', $auction->id)->orderBy('price', 'desc')->first();
             $highestbiduser = User::where('id', '=', $highestbid->user_id)->first();
             $emailwon = $highestbiduser->login->email;
             Mail::raw('The auction ended, you bought the auction ' . $auction->title, function ($message) use($emailwon) {
                 $message->to($emailwon)->subject('The auction ended, you bought the auction ');
                 $message->from('*****@*****.**');
             });
             // other bidders damn it mail
             $count = Bid::where('auction_id', '=', $auction->id)->count();
             $skip = 1;
             $limit = $count - $skip;
             // the limit
             $otherbids = Bid::where('auction_id', '=', $auction->id)->orderBy('price', 'desc')->skip($skip)->take($limit)->get();
             foreach ($otherbids as $key => $bid) {
                 $user = User::where('id', '=', $bid->user_id)->first();
                 $emaillose = $user->login->email;
                 Mail::raw('The auction ended, you lost the auction ' . $auction->title, function ($message) use($emaillose) {
                     $message->to($emaillose)->subject('The auction ended, you lost the auction ');
                     $message->from('*****@*****.**');
                 });
             }
         }
     }
 }
 public function composeSpotlight()
 {
     view()->composer('../reusable/spotlight', function ($view) {
         $spotlight = Auction::select(DB::raw('auctions.*, count(*) as `totalbids`'))->join('bids', 'auctions.id', '=', 'bids.auction_id')->groupBy('auction_id')->orderBy('totalbids', 'desc')->first();
         $view->with('spotlight', $spotlight);
     });
 }
 public function index()
 {
     $faqs = FaqCategory::find(1)->faqs;
     //alle faqs met category 'main' id '1'
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     return View::make('faq')->with('faqs', $faqs)->with('newestAuction', $newestAuction);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(AuctionCreateRequest $request)
 {
     $input = $request->all();
     $imgPath = 'img/uploads/';
     $timestamp = time();
     $fileProperties = ['img_artwork', 'img_signature', 'img_optional'];
     foreach ($fileProperties as $fileProperty) {
         if ($request->hasFile($fileProperty)) {
             $file = $request->file($fileProperty);
             $extension = $file->getClientOriginalExtension();
             $randomstring = self::generateRandomString(20);
             $filename = $timestamp . '-' . $randomstring . '.' . $extension;
             $file->move($imgPath, $filename);
             $input[$fileProperty] = '/' . $imgPath . $filename;
         }
     }
     $input['enddate'] = Carbon::createFromFormat('Y-m-d', $input['enddate']);
     $auction = Auction::create($input);
     $owner = Auth::user();
     $auction->owner()->associate($owner);
     $style = AuctionStyle::findOrFail($request->get('auction_style_id'));
     $auction->auctionstyles()->associate($style);
     $auction->save();
     return redirect()->route('myauctions.index');
 }
 public function state(Request $request)
 {
     $state = $request->input('state');
     $id = $request->input('id');
     Auction::where('id', $id)->update(['state' => $state]);
     return redirect()->back();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $auctions = Auction::all();
     foreach ($auctions as $auction) {
         $enddate = new DateTime($auction->enddate);
         $now = new Datetime();
         if ($enddate < $now) {
             $highest_bid = $auction->highest_bid;
             $auction_id = $auction->id;
             $highest_bidder = User::whereHas('bids', function ($q) use($highest_bid, $auction_id) {
                 $q->where('amount', '=', $highest_bid)->where('auction_id', '=', $auction_id);
             })->first();
             if ($highest_bidder) {
                 $bidders = User::whereHas('bids', function ($q) use($highest_bid, $auction_id) {
                     $q->where('auction_id', $auction_id)->where('amount', '>', $highest_bid);
                 })->get();
                 foreach ($bidders as $bidder) {
                     $this->info($auction->title . ' was not sold to ' . $bidder->email);
                     Mail::send('mails.loser', ['user' => $bidder], function ($ms) use($bidder) {
                         $ms->to($bidder->email, $bidder->company)->subject('Too bad!');
                     });
                 }
                 Mail::send('mails.winner', ['user' => $highest_bidder], function ($ms) use($highest_bidder) {
                     $ms->to($highest_bidder->email, $highest_bidder->company)->subject('Congratulations!');
                 });
                 $this->info($auction->title . ' was sold to ' . $highest_bidder->company);
             } else {
                 $auction->active = false;
                 $auction->expired = true;
                 $auction->save();
                 $this->info($auction->title . ' is expired.');
             }
         }
     }
 }
 public function index()
 {
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     $countries = ['default' => 'Kies een land'] + Country::orderby('nameDutch', 'ASC')->lists('nameDutch', 'id')->all();
     // $countriesEnglish = ['default'=>'Choose a country'] + Country::orderby('nameEnglish', 'ASC')->lists('nameEnglish', 'id')->all();
     return View::make('register')->with('countries', $countries)->with('newestAuction', $newestAuction);
 }
 public function index()
 {
     $recentAuctions = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->take(4)->get();
     $popularAuctions = Auction::with('bidders')->where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->get()->sortBy(function ($auction) {
         return $auction->bidders->count();
     })->take(3);
     return View::make('home')->with('recentAuctions', $recentAuctions)->with('popularAuctions', $popularAuctions);
 }
Beispiel #11
0
 /**
  * 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'));
 }
Beispiel #12
0
 protected function end()
 {
     $auctions = Auction::where('expires', '<', date('Y-m-d H:i:s'))->where('state', 'active')->get();
     foreach ($auctions as $auction) {
         $auction->state = 'expired';
         $auction->save();
     }
 }
Beispiel #13
0
 protected function mybids($id)
 {
     $mybids = Bid::where('bidder_id', $id)->get();
     foreach ($mybids as $bid) {
         $bid->auction = Auction::where('id', $bid->auction_id)->first();
     }
     return $mybids;
 }
 public function index()
 {
     // most popular bids top 3
     $arts = Auction::select(DB::raw('auctions.*, count(*) as `totalbids`'))->join('bids', 'auctions.id', '=', 'bids.auction_id')->groupBy('auction_id')->orderBy('totalbids', 'desc')->take(3)->get();
     // newest  auctions for in carousel
     $carousels = Auction::orderBy('published', 'desc')->take(5)->get();
     return view('welcome', compact('arts', 'carousels'));
 }
 /**
  * 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');
 }
Beispiel #16
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         Auction::end();
     })->everyMinute();
     $schedule->call(function () {
         Auction::setPopular();
     })->daily();
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show(Request $request)
 {
     $data = $request->all();
     $query = $data['search'];
     $locale = App::getLocale();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     $results = Auction::search($query)->get();
     return view('search.show', array('results' => $results, 'newest' => $newest, 'query' => $query));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function ask(Request $request)
 {
     $data = $request->all();
     $selectedAuction = $data['id'];
     $locale = App::getLocale();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     $auctions = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->where('status_id', 1)->orderBy('created_at', 'DESC')->get();
     return view('contact.index', array('newest' => $newest, 'auctions' => $auctions, 'selected' => $selectedAuction));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $locale = App::getLocale();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     $myBids = Auction::join('bids', 'bids.auction_id', '=', 'auctions.id')->where('bids.user_id', Auth::User()->id)->translatedIn($locale)->get();
     /**
      * Return all acutions
      */
     return view('my_bids.index', array('auctions' => $myBids, 'newest' => $newest));
 }
Beispiel #20
0
 public function contact($id = '')
 {
     $auctions = Auction::All();
     if ($id != '') {
         $selected = $auctions[$id - 1];
         return view('contact', ['auctions' => $auctions, 'selected' => $selected]);
     } else {
         return view('contact', ['auctions' => $auctions]);
     }
 }
Beispiel #21
0
 /**
  * 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]);
         }
     }
 }
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         $auctions = Auction::where('FK_status_id', '!=', '4')->get();
         //alle auctions ophalen die niet expired zijn
         $mytime = Carbon::now();
         //de datum nu
         $timenow = $mytime->toDateTimeString();
         foreach ($auctions as $auction) {
             if ($auction->enddate < $timenow) {
                 $auction->FK_status_id = '4';
                 //status van auction op expired zetten
                 $auction->save();
                 /*
                                     //alle bidders die op deze auction hebben geboden
                                     $bidders = Bidder::where('FK_auction_id', '=', $auction->id)->distinct()->with('user')->get(); //distinct voor duplicate receivers
                                     
                 //mail sturen naar verliezende bidders
                 foreach($bidders as $bidder)
                 {
                     if($bidder->bidAmount == $auction->currentPrice) //bidder heeft hoogste bod
                     {
                         //mail sturen naar bidders zonder hoogste bod
                         Mail::send('email.wonauction',
                             array(
                                 'descriptionEnglish' => $auction->descriptionEnglish,
                                 'descriptionDutch' => $auction->descriptionDutch,
                                 'title' => $auction->title
                             ), function($message)
                         {
                             $message->from('*****@*****.**');
                             $message->to($bidder->user->email, 'Admin')->subject('You have won an auction on Landoretti');
                         });
                         
                     }
                     else{
                         //mail sturen naar bidders zonder hoogste bod
                         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');
                         });
                     }
                 }
                 */
             }
         }
     })->everyMinute();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('auctions')->delete();
     $owner = User::first();
     $style_first = AuctionStyle::first();
     $style_random = AuctionStyle::orderByRaw("RAND()")->first();
     Auction::create(['owner_id' => $owner->id, 'auction_style_id' => $style_first->id, 'title' => 'La trahison des images - René Magritte', 'year' => 1928, 'width' => '63.5', 'height' => '93.98', 'depth' => null, 'description' => 'The Treachery of Images (sometimes translated as The Treason of Images) is a painting by the Belgian surrealist painter René Magritte.', 'condition' => 'Great', 'origin' => 'Belgium', 'img_artwork' => '/img/uploads/magritte_1.jpg', 'img_signature' => '/img/uploads/magritte_2.png', 'img_optional' => null, 'min_price' => '20000', 'max_price' => '1000000', 'buyout_price' => '1000000', 'enddate' => Carbon::parse('last wednesday')->format('Y-m-d')]);
     Auction::create(['owner_id' => $owner->id, 'auction_style_id' => $style_random->id, 'title' => 'Skrik - Edvard Munch', 'year' => 1893, 'width' => '91', 'height' => '73.5', 'depth' => null, 'description' => 'The Scream (Norwegian: Skrik) is the popular name given to each of four versions of a composition, created as both paintings and pastels, by the Expressionist artist Edvard Munch between 1893 and 1910. The Greman title Munch gave these works is Der Schrei der Natur (The Scream of Nature). The works show a figure with an agonized expression against a landscape with a tumultuous orange sky. Arthur Lubow has described The Scream as "an icon of modern art, a Mona Lisa for our time."', 'condition' => 'Okay', 'origin' => 'Oslo', 'img_artwork' => '/img/uploads/scream_1.jpg', 'img_signature' => '/img/uploads/scream_2.jpg', 'img_optional' => '/img/uploads/scream_3.jpg', 'min_price' => '7500', 'max_price' => '1355000', 'buyout_price' => '1000000', 'enddate' => Carbon::parse('next saturday')->format('Y-m-d')]);
     for ($i = 0; $i < 50; $i++) {
         Auction::create(['owner_id' => $owner->id, 'auction_style_id' => $style_random->id, 'title' => 'FILLER ' . $i, 'year' => rand(1000, 2000), 'width' => rand(10, 100), 'height' => rand(10, 100), 'depth' => null, 'description' => "FILLER DESCRIPTION Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.", 'condition' => 'Fine', 'origin' => 'World', 'img_artwork' => '/img/uploads/filler_' . rand(1, 8) . '.jpg', 'img_signature' => '/img/uploads/filler_' . rand(1, 8) . '.jpg', 'img_optional' => null, 'min_price' => rand(100, 1000), 'max_price' => rand(2000, 20000), 'buyout_price' => 20000, 'enddate' => Carbon::parse('next thursday')->format('Y-m-d')]);
     }
 }
 public function send(QuestionRequest $request)
 {
     $auction = Auction::getAuctionForId($request->artwork_id);
     $name = $request->name;
     $email = $request->email;
     $question = $request->question;
     Mail::send('emails.contact', ['name' => $name, 'question' => $question, 'auction' => $auction], function ($message) use($email, $name) {
         $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
         $message->to($email, $name)->subject('Thanks for contacting Landoretti!');
     });
     return Redirect::route('home');
 }
Beispiel #25
0
 public function getAuctions($keyword)
 {
     $results = Auction::where('title', 'like', '%' . $keyword . '%')->get();
     if (count($results) == 0) {
         $results = Auction::where('author', 'like', '%' . $keyword . '%')->get();
         if (count($results) == 0) {
             $results = Auction::where('style', 'like', '%' . $keyword . '%')->get();
         }
         return $results;
     } else {
         return $results;
     }
 }
Beispiel #26
0
 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);
     }
 }
 public function question(Request $request)
 {
     $this->validate($request, ['title' => 'required|exists:auctions,title', 'question' => 'required']);
     if ($request->input('confirmed')) {
         $auction = Auction::where('title', $request->input('title'))->first();
         $recipient = $auction->seller_id;
         $data = ['sender' => User::find(Auth::user()->id), 'message' => $request->input('question'), 'title' => $request->input('title'), 'recipient' => $recipient];
         Message::ask($data);
         Session::flash('flash_message', trans('messages.question.sent'));
         return redirect(\App::getLocale() . '/art');
     } else {
         return view('auctions.ask_conf')->with('message', $request);
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $locale = App::getLocale();
     /**
      * Return 4 latest auctions
      * Banner
      */
     $auctions = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('end_date', 'DESC')->take(4)->get();
     /**
      * Return 3 latest auctions
      * Popular
      */
     $popular = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('end_date', 'DESC')->take(3)->get();
     return view('home.index', array('auctions' => $auctions, 'popular' => $popular));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['id' => 'required']);
     $data = $request->all();
     $existing = Watchlist::where('user_id', Auth::user()->id)->where('auction_id', $data['id'])->first();
     if (!$existing) {
         $watchlist = new Watchlist();
         $watchlist->user_id = Auth::user()->id;
         $watchlist->auction_id = $data['id'];
         $watchlist->save();
     }
     $locale = App::getLocale();
     $watchlists = Auction::join('watchlist', 'watchlist.auction_id', '=', 'auctions.id')->where('watchlist.user_id', Auth::User()->id)->translatedIn($locale)->get();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     return view('watchlist.index', array('auctions' => $watchlists, 'newest' => $newest));
 }
 public function addToWatchlist($id)
 {
     $watchlistcheck = Watchlist::where('FK_auction_id', '=', $id)->where('FK_user_id', '=', Auth::user()->id)->first();
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     if ($watchlistcheck == null) {
         $newWatchlist = new Watchlist();
         $newWatchlist->FK_user_id = Auth::user()->id;
         $newWatchlist->FK_auction_id = $id;
         $newWatchlist->save();
         $watchlist = Watchlist::where('FK_user_id', '=', Auth::user()->id)->get();
         $success = 'You successfully added an auction to your watchlist!';
         return view('watchlist')->with('watchlist', $watchlist)->with('newestAuction', $newestAuction)->with('success', $success);
     } else {
         $watchlist = Watchlist::where('FK_user_id', '=', Auth::user()->id)->get();
         $warning = 'This auction was already added to your watchlist!';
         return view('watchlist')->with('watchlist', $watchlist)->with('newestAuction', $newestAuction)->with('warning', $warning);
     }
 }