/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 0; $i < 15; $i++) {
         $auction = new Art();
         $auction->user_id = 1;
         $auction->artist_id = 1;
         $auction->style_id = 1;
         $auction->title = "Dance of Time III";
         $auction->slug = "Dance-of-Time-III-" . $i;
         $auction->description_nl = "description in het nederlands";
         $auction->description_en = "description in het engels";
         $auction->condition_nl = "Condition in het nederlands";
         $auction->condition_en = "condition in het engels";
         $auction->width = "30cm";
         $auction->height = "70cm";
         $auction->depth = "2.5cm";
         $auction->color = "Bronze, patinated branze and gold";
         $auction->date_of_creation = "1979";
         $auction->est_low_price = 9500;
         $auction->est_high_price = 10500;
         $auction->buyout = 15000;
         $auction->sold = false;
         $auction->end_datetime = "2016-01-24 12:00:00";
         $auction->save();
     }
 }
Example #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;
 }
 public function postContact(Request $request)
 {
     $auction = Art::findorfail($request->input('auction'))->first();
     $auctionEmail = $auction->user->email;
     $data['receiver'] = $auctionEmail;
     $data['sender'] = $request->input('email');
     $data['question'] = $request->input('question');
     // send mail to owner of art
     Mail::send('emails.question', $data, function ($message) use($data) {
         $message->to($data['receiver'])->subject('I have a question about your auction');
     });
     return redirect()->route('home');
 }
Example #4
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'));
 }
 /**
  * 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";
     }
 }
 public function search(Request $request, $search, $sort = 'new', $class = null, $filter = null)
 {
     //check if something was searched
     if ($search == "") {
         return redirect()->route('home')->withErrors(['please fill in the searchbox']);
     }
     //get all FAQ found on search
     $FAQ = FAQ::where('question', 'like', '%' . $search . '%')->orwhere('answer', 'like', '%' . $search . '%')->get();
     //get all auctions found on search
     $artOutput = Art::selectRaw('art.*, max(bids.price) as highest_bid, count(bids.art_id) AS `count`')->leftJoin('bids', 'bids.art_id', '=', 'art.id')->groupBy('art.id')->where(function ($query) use($search) {
         $query->where('description_nl', 'like', '%' . $search . '%')->orWhere('description_en', 'like', '%' . $search . '%')->orWhere('title', 'like', '%' . $search . '%');
     })->where('art.processed', '0');
     //add filters to art
     $auctions = $this->add_filters($artOutput, $sort, $class, $filter);
     $auctions = $auctions->groupBy('bids.art_id')->paginate(9);
     $data['search'] = $search;
     $data['FAQ'] = $FAQ;
     $data['art'] = $auctions;
     $data['sort'] = $sort;
     $data['route'] = 'art.search';
     return View('search')->with($data);
 }
Example #7
0
 /**
  * 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');
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($id, Request $request)
 {
     $validation = $this->validator($request->all());
     $bids = Art::findOrFail($id)->bids()->get();
     $lower = false;
     foreach ($bids as $bid) {
         //check if bid is higher than all other bids on this item
         if ($bid->price >= $request->input('amount')) {
             $lower = true;
         }
     }
     //if bid isn't higher, run exception
     if ($lower) {
         return redirect()->back()->withErrors(['er is reeds hoger geboden op deze veiling']);
     } else {
         //else make bid
         $bid = new Bid();
         $bid->user_id = Auth::user()->id;
         $bid->art_id = $id;
         $bid->price = $request->input('amount');
         $bid->save();
         return redirect()->back()->withSuccess('succesvol geboden!');
     }
 }
Example #9
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'));
 }
Example #10
0
 public function delete($art_id)
 {
     Art::where('id', $art_id)->delete();
     return redirect()->route('admin')->withSuccess('succesvol verwijderd');
 }
Example #11
0
 public function activate($id)
 {
     $art = Art::whereId($id)->first();
     if ($art) {
         if ($art->active == 0) {
             $art->active = 1;
         } else {
             $art->active = 0;
         }
         $art->save();
         return Redirect::route('art.index')->with('message', 'Obra actualizada');
     } else {
         return Redirect::route('art.index')->with('message', 'Error. Obra no encontrada');
     }
 }
 public function buyNow($id)
 {
     $art = Art::findorfail($id);
     if ($art->sold()->count() > 0) {
         return redirect()->back()->withErrors(['this item was already sold']);
     }
     $buyer = Auth::user();
     $sold = new Sold();
     $sold->art_id = $art->id;
     $sold->buyer_id = $buyer->id;
     $sold->save();
     $art->sold = 1;
     $art->save();
     $data['art'] = $art;
     return View('Art.bought')->with($data);
 }
Example #13
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'));
 }