/**
  * 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 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));
 }
 /**
  * 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));
 }
 /**
  * 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 filterPrice(Request $request)
 {
     $locale = App::getLocale();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     $data = $request->all();
     if ($data['id'] == 1) {
         $query = Auction::where('buyout_price', '<=', 5000);
     } elseif ($data['id'] == 2) {
         $query = Auction::where('buyout_price', '>', 5000)->where('buyout_price', '<=', 10000);
     } elseif ($data['id'] == 3) {
         $query = Auction::where('buyout_price', '>', 10000)->where('buyout_price', '<=', 25000);
     } elseif ($data['id'] == 4) {
         $query = Auction::where('buyout_price', '>', 2500)->where('buyout_price', '<=', 50000);
     } elseif ($data['id'] == 5) {
         $query = Auction::where('buyout_price', '>', 50000)->where('buyout_price', '<=', 100000);
     } else {
         $query = Auction::where('buyout_price', '>', 10000);
     }
     $auctions = $query->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->paginate(8);
     return view('art.index', array('auctions' => $auctions, 'newest' => $newest));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function bid(Request $request)
 {
     $this->validate($request, ['id' => 'required', 'bid' => 'required']);
     $data = $request->all();
     $bid = new App\Bid();
     $bid->user_id = Auth::user()->id;
     $bid->auction_id = $data['id'];
     $bid->price = $data['bid'];
     $bid->save();
     $locale = App::getLocale();
     $highestbid = App\Bid::where('auction_id', $bid->auction_id)->orderBy('price', 'DESC')->first();
     $auction = Auction::where('id', $bid->auction_id)->first();
     if ($highestbid->price > $auction->current_price) {
         $auction->current_price = $highestbid->price;
         $auction->save();
     }
     $bids = Auction::join('bids', 'bids.auction_id', '=', 'auctions.id')->where('bids.user_id', Auth::User()->id)->translatedIn($locale)->get();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     return view('my_bids.index', array('auctions' => $bids, 'newest' => $newest));
 }
 /**
  * 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();
     return view('faq.index', array('newest' => $newest));
 }