public function contact(Art $auction)
 {
     if (!$auction->id) {
         $allAuctions = Art::where('processed', '0')->get();
         $data['allAuctions'] = $allAuctions;
     } else {
         $data['auction'] = $auction;
     }
     return View('Main.contact')->with($data);
 }
예제 #2
0
 public function onePiece()
 {
     $now = Carbon::now();
     $onePiece = Art::where('sold', 0)->where('ending', '>', $now)->orderBy(\DB::raw('RAND()'))->join('pictures', 'arts.id', '=', 'pictures.art_id')->select('pictures.path', 'arts.description', 'arts.title', 'arts.id')->first();
     if (!empty($onePiece)) {
         $onePiece->shortdesc = implode(' ', array_slice(explode(' ', $onePiece->description), 0, 25)) . "...";
     } else {
         $onePiece = 'empty';
     }
     return $onePiece;
 }
예제 #3
0
 public function myBids()
 {
     $mybids = Bid::where('user_id', Auth::user()->id)->orderby('art_id')->orderby('bid', 'desc')->get();
     $allBids = array();
     foreach ($mybids as $bid) {
         $art = Art::where('id', $bid->art_id)->where('sold', 0)->first();
         if ($art) {
             $bid['title'] = $art->title;
             $bid['ending'] = $art->ending;
             $allBids[] = $bid;
         }
     }
     $iBought = Art::where('sold_to', Auth::user()->id)->get();
     return View('profile.mybids', compact('allBids', 'iBought'));
 }
예제 #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->comment(PHP_EOL . Inspiring::quote() . PHP_EOL);
     $auctions = Art::where('art.end_datetime', '<', Carbon::now())->where('art.processed', '0')->get();
     // $test = $test;
     foreach ($auctions as $art) {
         $bids = $art->bids()->orderBy('price', 'DESC')->get();
         // var_dump($bids);
         if (count($bids)) {
             $winner = $bids->first();
             // var_dump($winner);
             $allMails = [];
             array_push($allMails, $winner->user->email);
             $loserMails = [];
             foreach ($bids as $bid) {
                 $email = $bid->user->email;
                 // echo $email;
                 if (!in_array($email, $allMails)) {
                     array_push($allMails, $email);
                     array_push($loserMails, $email);
                 }
             }
             $data = [];
             $data['winner'] = $winner->user;
             $data['auction-name'] = $art->title;
             Mail::send('emails.auction-win', $data, function ($message) use($data) {
                 $message->to($data['winner']->email)->subject('U heeft de auction gewonnen');
             });
             foreach ($loserMails as $mail) {
                 $data['mail'] = $mail;
                 Mail::send('emails.auction-lose', $data, function ($message) use($data) {
                     $message->to($data['mail'])->subject('U heeft de auction niet gewonnen');
                 });
             }
             $art->sold = 1;
         }
         $art->processed = 1;
         $art->save();
         echo $art->title . "\n";
     }
 }
예제 #5
0
파일: Kernel.php 프로젝트: jonasvr/auction
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         $today = Carbon::today();
         //alle auctions ophalen die eindigen
         $arts = Art::where('ending', "<", $today)->where('sold', 0)->get();
         // alle bidders afgaan
         foreach ($arts as $art) {
             $bidder = bid::where('bid', $art->highest())->where('art_id', $art->id)->select('user_id', 'bid')->first();
             if (!$bidder) {
                 $art->sold_for = 0;
                 $art->sold_to = 0;
                 $input = new notification();
                 $input->user_id = $art->user_id;
                 $input->notification = $bidder->title . " hasn't been sold before closing.";
                 $input->save();
             } else {
                 $art->sold_for = $bidder->bid;
                 $art->sold_to = $bidder->user_id;
                 $this->notification($art->id, $bidder->user_id);
                 //melding sturen naar alle bieders/geintresseerde die het niet verkregen
                 $input = new notification();
                 $input->user_id = $bidder->user_id;
                 $input->notification = $art->title . " is yours for " . $bidder->bid . " euro";
                 //
                 $input->save();
             }
             $art->sold = 1;
             Bid::where('art_id', $art->id)->delete();
             watchlist::where('art_id', $art->id)->delete();
             $art->save();
         }
         Mail::send('email.test', ['name' => 'jonas'], function ($message) {
             $message->to('*****@*****.**', 'test')->subject('welcome!');
         });
     })->dailyAt('00:01');
 }
예제 #6
0
 public function searchFiltert($filter, $value)
 {
     $search = Session::get('search');
     $now = Carbon::now();
     $random_art = Art::where('sold', 0)->where('ending', '>', $now)->where(function ($query) use($search) {
         $query->where('title', 'like', '%' . $search . '%')->orWhere('description', 'like', '%' . $search . '%');
     })->where(function ($query) use($filter, $value) {
         switch ($filter) {
             case 'style':
                 $query->where('style_id', $value);
                 break;
             case 'era':
                 $query->where('era_id', $value);
                 break;
             case 'price':
                 $lower = $this->filterOnPrice($value);
                 if ($value == 'up') {
                     $query->where('price', '>', $lower);
                 } else {
                     $query->whereBetween('price', [$lower, $value + 1]);
                     //$query->where('price','<',$value);
                 }
                 break;
             case 'when':
                 switch ($value) {
                     case 'weekend':
                         $when = $this->filterOnWhen($value);
                         $query->where('ending', '<', $when);
                         break;
                     case 'new':
                         $tomorrow = Carbon::tomorrow();
                         $query->where('created_at', '<', $tomorrow);
                         break;
                 }
                 break;
         }
     })->paginate(8);
     $picture = $this->getPicture($random_art);
     $duration = $this->getDuration($random_art, $now);
     $VoS = 'searchFilter';
     $title = 'Search';
     $onePiece = $this->onePiece();
     $path = $search;
     $path .= ' > ' . $this->getPath($filter, $value);
     return View('art.overview', compact('random_art', 'VoS', 'duration', 'picture', 'title', 'onePiece', 'path'));
 }
예제 #7
0
 public function delete($art_id)
 {
     Art::where('id', $art_id)->delete();
     return redirect()->route('admin')->withSuccess('succesvol verwijderd');
 }
 public function myAuctions()
 {
     $active = Art::where('user_id', Auth::user()->id)->where('processed', '0')->where('sold', '0')->get();
     $sold = Art::where('user_id', Auth::user()->id)->where('processed', '1')->where('sold', '1')->get();
     $expired = Art::where('user_id', Auth::user()->id)->where('processed', '1')->where('sold', '0')->get();
     $allAuctions = Art::where('user_id', Auth::user()->id)->get();
     //pending = no bids, but not over yet
     $pending = collect([]);
     foreach ($allAuctions as $auction) {
         if (!count($auction->bids) && $auction->processed == '0') {
             $pending->push($auction);
         }
     }
     $data['pending'] = $pending;
     $data['active'] = $active;
     $data['expired'] = $expired;
     $data['sold'] = $sold;
     return View('Art.myAuctions')->with($data);
 }
예제 #9
0
 public function buyNow($art_id)
 {
     $art = Art::where('id', $art_id)->where('sold', 0)->firstOrFail();
     $art->sold = 1;
     $art->sold_for = $art->price;
     $art->sold_to = Auth::user()->id;
     $art->save();
     $this->notification($art->id, Auth::user()->id);
     Bid::where('art_id', $art_id)->delete();
     watchlist::where('art_id', $art_id)->delete();
     return redirect()->route('/')->withSuccess(trans('succes.bought'));
 }