/**
  * 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 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 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);
 }
 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);
 }
 public function state(Request $request)
 {
     $state = $request->input('state');
     $id = $request->input('id');
     Auction::where('id', $id)->update(['state' => $state]);
     return redirect()->back();
 }
Exemple #6
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()
 {
     $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);
 }
Exemple #8
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();
     }
 }
 /**
  * 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();
 }
 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;
     }
 }
 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);
     }
 }
 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);
     }
 }
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|max:255', 'email' => 'required|email|max:255', 'message' => 'required|max:255']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $input = $request->all();
     $auctionid = explode(',', $input['auction']);
     $auction = Auction::find($auctionid[0]);
     Mail::send('email.contactmail', array('name' => $input['name'], 'email' => $input['email'], 'user_message' => $input['message'], 'auctionTitle' => $auction->title), function ($message) {
         $message->from('*****@*****.**');
         $message->to('*****@*****.**', 'Admin')->subject('Landoretti Question');
     });
     $auctions = ['default' => 'Choose an auction'] + Auction::orderby('title', 'ASC')->lists('title', 'id')->all();
     $success = 'Thanks for contacting us!';
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     return view('contact')->with('newestAuction', $newestAuction)->with('success', $success)->with('auctions', $auctions);
 }
 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));
 }
 public function myauctions()
 {
     $auctions = Auction::where('user_id', '=', Auth::user()->User->id)->get();
     return view('my_auctions', compact('auctions'));
 }
 /**
  * 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));
 }
 public function getMaxPrice($id)
 {
     $art = Auction::where('id', '=', $id)->first();
     return $art->price_max;
 }
Exemple #18
0
 public static function getExpiringAuctions()
 {
     return Auction::where('enddate', '=', Carbon::now()->format('Y-m-d'))->get();
 }

<?php 
$statistic = \Illuminate\Support\Facades\Cache::remember('statistic', 10, function () use($globalSiteSettings) {
    $statistic = [];
    $receivedUSD = \App\Auction::where('currency', '=', 'USD')->get();
    $receivedUAH = \App\Auction::where('currency', '=', 'UAH')->get();
    $receivedEUR = \App\Auction::where('currency', '=', 'EUR')->get();
    $receivedUSD_sum = $receivedUSD->sum('starting_price') * $globalSiteSettings['usd_cyr'];
    $receivedEUR_sum = $receivedEUR->sum('starting_price') * $globalSiteSettings['eur_cyr'];
    $receivedUAH_sum = $receivedUAH->sum('starting_price');
    $statistic['receivedCount'] = $receivedUSD->count() + $receivedUAH->count() + $receivedEUR->count();
    $statistic['receivedSum'] = $receivedUSD_sum + $receivedEUR_sum + $receivedUAH_sum;
    $conductedUSD = \App\Auction::where('currency', '=', 'USD')->where('status', '=', 7)->get();
    $conductedUAH = \App\Auction::where('currency', '=', 'UAH')->where('status', '=', 7)->get();
    $conductedEUR = \App\Auction::where('currency', '=', 'EUR')->where('status', '=', 7)->get();
    $conductedUSD_sum = $conductedUSD->sum('starting_price') * $globalSiteSettings['usd_cyr'];
    $conductedEUR_sum = $conductedEUR->sum('starting_price') * $globalSiteSettings['eur_cyr'];
    $conductedUAH_sum = $conductedUAH->sum('starting_price');
    $statistic['conductedCount'] = $conductedUSD->count() + $conductedUAH->count() + $conductedEUR->count();
    $statistic['conductedSum'] = $conductedUSD_sum + $conductedEUR_sum + $conductedUAH_sum;
    return $statistic;
});
?>

<div class="auctions_stat">
        <div class="text-center col col-md-6 col-xs-12">Отримано {{ $statistic['receivedCount']  }} заявок на суму: <span>{{ number_format($statistic['receivedSum'], 0, ',', ' ') }} грн</span></div>
        <div class="text-center col col-md-6 col-xs-12">Проведено {{ $statistic['conductedCount'] }} торгів на суму: <span>{{ number_format($statistic['conductedSum'], 0, ',', ' ') }} грн</span></div>
  </div>

    </div>
 public function items()
 {
     $sort = Input::get('sortBy');
     switch ($sort) {
         case 'endingsoonest':
             $auctions = Auction::where(['active' => true])->orderBy('enddate', 'DESC')->paginate(8);
             break;
         case 'endinglatest':
             $auctions = Auction::where(['active' => true])->orderBy('enddate', 'ASC')->paginate(8);
             break;
         case 'popular':
             $auctions = Auction::where(['active' => true])->orderBy('bid_amount', 'DESC')->paginate(8);
             break;
     }
     $price = Input::get('price');
     switch ($price) {
         case '0-5000':
             $auctions = Auction::where(['active' => true])->where('estprice', '>', '0')->where('estprice', '<=', '5000')->paginate(8);
             break;
         case '5000-10000':
             $auctions = Auction::where(['active' => true])->where('estprice', '>', '5000')->where('estprice', '<=', '10000')->paginate(8);
             break;
         case '10000-25000':
             $auctions = Auction::where(['active' => true])->where('estprice', '>', '10000')->where('estprice', '<=', '25000')->paginate(8);
             break;
         case '25000-50000':
             $auctions = Auction::where(['active' => true])->where('estprice', '>', '25000')->where('estprice', '<=', '50000')->paginate(8);
             break;
         case '50000-100000':
             $auctions = Auction::where(['active' => true])->where('estprice', '>', '50000')->where('estprice', '<=', '100000')->paginate(8);
             break;
         case '10000-more':
             $auctions = Auction::where(['active' => true])->where('estprice', '>', '100000')->paginate(8);
             break;
     }
     if ($auctions) {
         foreach ($auctions as $auction => $loop) {
             $loop->remaining_time = $this->auction->convertToRemainingTime($loop->enddate);
         }
     }
     return view('auctions.index', compact('auctions', 'sort', 'price'));
 }
 public function autocomplete()
 {
     $result = Auction::where('state', 'active')->select('title')->get();
     return json_encode($result);
 }
                <li><a href="{{action('AuctionsController@getRegister')}}"><i class="reg"></i>Реєстрація</a></li>
                @endif
            </ul>
        </div>
    </nav>
    </div>
</div>

<div id="auctions_counts">
    <div class="container">
    <div class="row">
        <?php 
$auction_count = \App\Auction::all();
?>
        <?php 
$auction_count2 = \App\Auction::where('status', '=', 7)->get();
?>
        <div class="col-xs-6 count">Отримано {{ $auction_count->count() }} заявок на сумму: <span>{{ number_format($auction_count->sum('starting_price'), 0, ',', ' ') }} грн</span></div>
        <div class="col-xs-6 count">Проведено {{ $auction_count2->count() }} торгів на сумму: <span>{{ number_format($auction_count2->sum('final_price'), 0, ',', ' ') }} грн</span></div>
    </div>
    </div>
</div>

@yield('content')

<footer id="main_footer">
    <div class="container">
        <div class="row">
            <div class="col-xs-3 col-md-3">
                <div class="logo"></div>
                <div class="copyright">@lang('theme.copyright')</div>
 public function profile()
 {
     $user = User::where('login_id', '=', Auth::id())->first();
     $auctions = Auction::where('user_id', '=', Auth::user()->User->id)->where('active', '=', true)->get();
     return view('my_profile', compact('user', 'auctions'));
 }
 public function myBids()
 {
     $bids = Bidder::where('FK_user_id', '=', Auth::user()->id)->with('auction')->orderBy('bidAmount', 'desc')->get();
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     return view('my-bids')->with('bids', $bids)->with('newestAuction', $newestAuction);
 }
 public function buyout($id)
 {
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     $auction = Auction::find($id);
     $lostbidders = Bidder::where('FK_auction_id', '=', $auction->id)->distinct()->with('user')->get();
     //distinct voor duplicate receivers
     if (Auth::user()->id == $auction->FK_user_id) {
         $warning = 'This is your own item!';
         return redirect()->back()->with('warning', $warning);
     }
     $auction->FK_status_id = '5';
     //sold
     $auction->save();
     //mail sturen naar andere bieders
     foreach ($lostbidders as $bidder) {
         if ($bidder->FK_user_id != Auth::user()->id) {
             //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');
             });
         }
     }
     return View::make('buynow')->with('newestAuction', $newestAuction);
 }
<div id="last_lots">
    <h3>Останні надходження</h3>
    <?php 
$wg = \App\Auction::where('status', '>', 0)->orderBy('created_at', 'desc')->take(3)->get();
?>

    @foreach($wg as $item)
    <div class="item clearfix">
        <a href="{{action('AuctionsController@getAuctionPage', ['id' => $item->id])}}">
        <div class="image"><img src="{{ $item->img_min }}" alt=""></div>
        <div class="info">
            <h2>{{ $item->title }}</h2>
            <div class="cost">Стартова ціна: <span>{{ number_format($item->starting_price, 2, ',', ' ') }} грн. </span></div>
        </div>
        </a>
    </div>
    @endforeach
</div>

<style>
    #last_lots {
        margin-top: 30px;
    }

    #last_lots .item {
        margin-top: 20px;
    }

    #last_lots .item .image {
        height: 150px;
        overflow: hidden;
 public function styleFilter()
 {
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     switch (Input::get('type')) {
         case '1':
             $auctions = Auction::where('FK_style_id', '=', 1)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '2':
             $auctions = Auction::where('FK_style_id', '=', 2)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '3':
             $auctions = Auction::where('FK_style_id', '=', 3)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '4':
             $auctions = Auction::where('FK_style_id', '=', 4)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '5':
             $auctions = Auction::where('FK_style_id', '=', 5)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '6':
             $auctions = Auction::where('FK_style_id', '=', 6)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '7':
             $auctions = Auction::where('FK_style_id', '=', 7)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '8':
             $auctions = Auction::where('FK_style_id', '=', 8)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '9':
             $auctions = Auction::where('FK_style_id', '=', 9)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '10':
             $auctions = Auction::where('FK_style_id', '=', 10)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '11':
             $auctions = Auction::where('FK_style_id', '=', 11)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '12':
             $auctions = Auction::where('FK_style_id', '=', 12)->orderBy('created_at', 'desc')->paginate(9);
             break;
         case '13':
             $auctions = Auction::where('FK_style_id', '=', 13)->orderBy('created_at', 'desc')->paginate(9);
             break;
     }
     return view('overview')->with('newestAuction', $newestAuction)->with('auctions', $auctions);
 }
 public function detail($art_id)
 {
     $art = Auction::where('id', '=', $art_id)->first();
     if ($art->active == false || $art->end_date < Carbon::now()) {
         return Redirect::route('arts');
     } else {
         $auctions = Auction::where('artist', 'like', '%' . $art->artist . '%')->orWhere('year', '=', $art->year)->orWhere('title', 'like', '%' . $art->title . '%')->orderBy('end_date', 'asc')->get();
         $bids = Bid::where('auction_id', '=', $art_id)->count();
         return view('product_detail', compact('auctions', 'art', 'bids'));
     }
 }
 /**
  * Генерирует sitemap.xml
  *
  */
 public function getSitemap()
 {
     $auctions = Cache::remember('auctions_sitemap', 3600, function () {
         $auctions = Auction::where('status', '>', 0)->get();
         return $auctions;
     });
     $pages = Cache::remember('pages_sitemap', 3600, function () {
         $pages = Pages::all();
         return $pages;
     });
     $news = Cache::remember('news_sitemap', 3600, function () {
         $news = News::where('date_publish', '<=', Carbon::parse(Carbon::now())->format('Y-m-d H:i'))->get();
         return $news;
     });
     $xml = view('sitemap', ['auctions' => $auctions, 'pages' => $pages, 'news' => $news]);
     return response($xml)->header('Content-Type', 'text/xml; charset=utf-8');
 }
 public function postUpdateLot(Request $request, $id)
 {
     $category = Cat::find($request->lot_category);
     // Категория в которую добавляем лот
     // Обязательные поля для заполнения: название, категория, область,
     $rights = ['lot_title' => 'required', 'lot_category' => 'required', 'region' => 'required', 'city' => 'required'];
     // Если категория имеет подкатегории - добавляем указание подкатегории обязательным для заполнения полем
     if ($category->children()->count() > 0) {
         $rights = array_add($rights, 'lot_type', 'required');
         // Тип лота
     }
     // Если добавлены прикрепления - добавляем валидацию по расширению файла
     if ($request->hasFile('documents')) {
         //$rights = array_add($rights, 'documents', 'mimes:jpeg,bmp,png,pdf,doc,docx');
     }
     // Если объект свободной продажи
     if ($request->free_sale) {
         // Если выбрана договорная цена - поле стоимости необязательно для заполнения
         if (!$request->negotiable_price) {
             $rights = array_add($rights, 'starting_price', 'required');
             // Стоимость
         }
     } else {
         $rights = array_add($rights, 'starting_price', 'required');
         // Стоимость
         $rights = array_add($rights, 'guarantee_fee', 'required');
         // Гарантийный взнос
         $rights = array_add($rights, 'bid_price', 'required');
         // Цена шага
         $rights = array_add($rights, 'data_start', 'required');
         // Дана начала аукциона
         $rights = array_add($rights, 'date_end', 'required');
         // Дата завершения
     }
     // Запрашиваем список обязательных полей для текущей категории и типа лота
     $rights = $this->getRightsForCategory($request->lot_category, $request->lot_type, $rights);
     // Собственный текст для ошибок
     $messages = array('lot_title.required' => 'Поле «Назва лоту» обязательно для заполнения.', 'lot_category.required' => 'Вы не выбрали категорию лота.', 'lot_image.required' => 'Нужно загрузить хотя бы основную фотографию лота.', 'region.required' => 'Вы не выбрали область.', 'city.required' => 'Поле «Місто» обязательно для заполнения.', 'starting_price.required' => 'Поле «Стартова ціна» обязательно для заполнения.', 'guarantee_fee.required' => 'Поле «Гарантійний внесок» обязательно для заполнения.', 'bid_price.required' => 'Поле «Крок аукціону» обязательно для заполнения.', 'data_start.required' => 'Поле «Дата початку аукціону» обязательно для заполнения.', 'date_end.required' => 'Поле «Дата завершення аукціону» обязательно для заполнения.', 'property_material.required' => 'Вы не выбрали материал здания.', 'property_floors.required' => 'Поле «Кiлькiсть поверхiв» обязательно для заполнения.', 'property_floor.required' => "Поле «Поверх» обов'язково для заповнення.", 'property_areas.required' => 'Поле «Кiмнат/примiщень» обязательно для заполнения.', 'property_totalarea.required' => 'Поле «Загальна площа» обязательно для заполнения.', 'property_livingarea.required' => 'Поле «Житлова площа» обязательно для заполнения.', 'auto_mark.required' => 'Вы не выбрали марку автомобиля.', 'auto_model.required' => 'Поле «Модель» обязательно для заполнения.', 'auto_year.required' => 'Поле «Pік випуску» обязательно для заполнения.', 'auto_transmission.required' => 'Поле «Коробка передач» обязательно для заполнения.', 'auto_drive.required' => 'Поле «Тип привода» обязательно для заполнения.', 'auto_fuel.required' => 'Поле «Тип пального» обязательно для заполнения.', 'auto_doors.required' => 'Поле «Кількість дверей» обязательно для заполнения.');
     // Если добавлены прикрепления - добавляем валидацию по расширению файла
     if ($request->hasFile('documents')) {
         //$rights = array_add($rights, 'documents', 'mimes:jpeg,bmp,png,pdf,doc,docx');
         $files = $request->file('documents');
         $i = 0;
         foreach ($files as $file) {
             //$rights = array_add($rights, 'documents'. $i, 'max:8000');
             $messages['documents.' . $i . '.max'] = 'Розмір файлу «' . $file->getClientOriginalName() . '» перевищує достустимый (8 мб).';
             $rights['documents.' . $i] = 'max:8000';
             $i++;
         }
     }
     // Выполняем валидацию
     $validator = Validator::make($request->all(), $rights, $messages);
     // При обнаружении ошибки - возвращаем пользователя на предыдущую страницу и выводим ошибки
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator->errors());
     }
     /*
      * Обновление информации о лоте
      */
     $create = Auction::where('id', '=', $id)->with('bidders')->first();
     $create->title = $request->lot_title;
     $create->category = $request->lot_category;
     $create->lot_type = $request->lot_type;
     $this->getAddFieldsListCategory($request->lot_category, $create, $request);
     $create->more_information = $request->more_information;
     // Додаткові відомості
     $create->more_about = $request->more_about;
     // Відомості про майно, його склад, характеристики, опис
     $create->region = $request->region;
     // Область
     $create->city = $request->city;
     // Місцезнаходження
     $create->property_type = $request->property_type;
     // Тип майна
     $create->currency = $request->currency;
     // Валюта
     if ($request->lot_image) {
         $create->img = $request->lot_image;
         $create->img_min = $request->lot_image_min;
     } else {
         $create->img = "http://uace.com.ua/static/images/no-picture-max.jpg";
         $create->img_min = "http://uace.com.ua/static/images/no-picture-min.jpg";
     }
     // Если есть основная фотография
     if ($request->lot_image) {
         $create->img = $request->lot_image;
         $create->img_min = $request->lot_image_min;
     } else {
         // Если нет, ставим стандартные
         $create->img = "http://uace.com.ua/static/images/no-picture-max.jpg";
         $create->img_min = "http://uace.com.ua/static/images/no-picture-min.jpg";
     }
     // Если установлен флажок на "Свободная продажа"
     if ($request->free_sale) {
         $create->free_sale = 1;
         // Помечаем как свободно продаваемый объект
         // Если установлен флажок на "Ціна договірна"
         if ($request->negotiable_price) {
             $create->negotiable_price = 1;
             $create->starting_price = null;
         } else {
             // В противном случае записываем введенную цену
             $create->starting_price = str_replace(" ", "", $request->starting_price);
             $create->negotiable_price = null;
         }
         $create->data_start = null;
         // Записываем дату начала
         $create->date_end = null;
         // Записываем дату завершения
         $create->guarantee_fee = null;
         // Гарантийный взнос
         $create->bid_price = null;
         // Стоимость шага
     } else {
         $create->free_sale = null;
     }
     // Если добавлен предмет на аукцион
     if (!$request->free_sale) {
         $create->free_sale = null;
         // Помечаем, что это не свободная продажа
         $create->data_start = Carbon::parse($request->data_start)->format('Y-m-d H:i');
         // Записываем дату начала
         $create->date_end = Carbon::parse($request->date_end)->format('Y-m-d H:i');
         // Записываем дату завершения
         $create->guarantee_fee = str_replace(" ", "", $request->guarantee_fee);
         // Гарантийный взнос
         $create->starting_price = str_replace(" ", "", $request->starting_price);
         // Стартовую цену
         $create->bid_price = str_replace(" ", "", $request->bid_price);
         // Стоимость шага
     }
     // Если установлен флажок на "Можливий торг"
     if ($request->possible_bargain) {
         $create->possible_bargain = 1;
     } else {
         $create->possible_bargain = null;
     }
     // Если выбран статус Архив
     if ($request->in_archive) {
         $create->in_archive = 1;
         $create->save();
     } else {
         $create->in_archive = 0;
         $create->save();
     }
     if ($create->status === $request->status) {
         $create->status = $request->status;
         $create->save();
     } elseif (!$create->free_sale && $request->status == 2) {
         $this->sendNotificationToUser($create->user, 3, 'default', $create->id, $create->title);
         // Отправка оповещения владельцу
         $create->status = 2;
         $create->save();
     } elseif (!$create->free_sale && $request->status == 3) {
         $this->sendNotificationAllBidders($create->id, $create->title, $create->bidders);
         // Отправка оповещения всем допущенным участникам
         $create->status = 3;
         $create->save();
     } elseif ($create->free_sale && $request->status == 3 || $create->free_sale && $request->status == 5 || $create->free_sale && $request->status == 7) {
         $this->sendNotificationToUser($create->user, $request->status, 'free', $create->id, $create->title);
         if ($request->status == 7) {
             $create->in_archive = 1;
             // Помещаем аукцион в Архив
         } elseif ($request->status == 3) {
             $create->in_archive = 0;
         }
         $create->status = $request->status;
         $create->save();
     } elseif (!$create->free_sale && $request->status == 7) {
         $user = App\User::find($create->user);
         // Информация о создателе аукциона
         $win = App\Bets::where('auction_id', '=', $create->id)->orderBy('created_at', 'desc')->first();
         // Определение победителя
         $create->in_archive = 1;
         // Помещаем аукцион в Архив
         if ($win) {
             $win_user = App\User::find($win->user_id);
             // Информация о победителе
             $win_status = App\Bidders::where('auction_id', '=', $create->id)->where('user_id', '=', $win->user_id)->first();
             $win_status->status = 2;
             $win_status->save();
             $create->final_price = $win->bet;
             $create->status = 7;
             // Смена статуса на "Торги відбулися"
             $create->save();
             // Отправка письма создателю аукциона
             Mail::queue('emails.auction-end', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'middle_name' => $user->middle_name, 'auction_id' => $create->id, 'auction_cyr' => $create->currency, 'auction_title' => $create->title, 'auction_status' => 7, 'win_first_name' => $win_user->first_name, 'win_last_name' => $win_user->last_name, 'win_middle_name' => $win_user->middle_name, 'win_email' => $win_user->email, 'win_phone' => $win_user->phone, 'win_cost' => $win->bet], function ($message) use($user) {
                 $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Аукціон завершено');
             });
             // Отправка письма победителю аукциона
             Mail::queue('emails.auction-end-winner', ['first_name' => $win_user->first_name, 'last_name' => $win_user->last_name, 'auction_id' => $create->id, 'auction_title' => $create->title, 'auction_status' => 7, 'win_cost' => $win->bet], function ($message) use($win_user) {
                 $message->to($win_user->email, $win_user->first_name . ' ' . $win_user->last_name)->subject('Аукціон завершено');
             });
             // Отправка письма администратору
             $adminEmail = $this->globalSiteSettings['admin_email'];
             Mail::queue('emails.auction-end-admin', ['auction_id' => $create->id, 'auction_title' => $create->title, 'auction_status' => 7, 'win_first_name' => $win_user->first_name, 'win_last_name' => $win_user->last_name, 'win_middle_name' => $win_user->middle_name, 'win_email' => $win_user->email, 'win_phone' => $win_user->phone, 'win_cost' => $win->bet], function ($message) use($adminEmail) {
                 $message->to($adminEmail)->subject('Аукціон завершено');
             });
         } else {
             $create->status = 8;
             // Смена статуса на "Торги не відбулися"
             $create->save();
             // Отправка письма создателю аукциона
             Mail::queue('emails.auction-end', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'middle_name' => $user->middle_name, 'auction_id' => $create->id, 'auction_title' => $create->title, 'auction_status' => 8], function ($message) use($user) {
                 $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Аукціон завершено');
             });
             // Отправка письма администратору
             $adminEmail = $this->globalSiteSettings['admin_email'];
             Mail::queue('emails.auction-end-admin', ['auction_id' => $create->id, 'auction_title' => $create->title, 'auction_status' => 8], function ($message) use($adminEmail) {
                 $message->to($adminEmail)->subject('Аукціон завершено');
             });
         }
     } else {
         $create->status = $request->status;
         $create->save();
     }
     if ($request->more_images) {
         $attaches = App\Uploads::find($request->more_images);
         foreach ($attaches as $attach) {
             $attach->auction_id = $create->id;
             $attach->type = 'image';
             $attach->save();
         }
     }
     if ($request->hasFile('documents')) {
         $files = $request->file('documents');
         foreach ($files as $file) {
             $surl = $this->globalSiteSettings['site_url'];
             $filename = preg_replace('/.[^.]*$/', '', $file->getClientOriginalName());
             $filename = $filename . '-' . mt_rand(10, 100) . '.' . $file->getClientOriginalExtension();
             $genLink = $surl . '/uploads/docs/' . $filename;
             // Генерируем ссылку
             $file->move(public_path() . '/uploads/docs/', $filename);
             // Перемещаем файл
             $upload = new App\Uploads();
             // Создаем экземпляр модели
             $upload->type = 'doc';
             // Задаем тип экземпляра - документ
             $upload->link = $genLink;
             // Записываем сгенерированную ранее ссылку
             $upload->name = preg_replace('/.[^.]*$/', '', $file->getClientOriginalName());
             // Записываем имя
             $upload->auction_id = $create->id;
             // Записываем сгенерированную ранее ссылку
             $upload->save();
             // Сохраняем
         }
     }
     // Сбрасываем закешированные данные виджета "Останні надходження"
     if (Cache::has('last_lots')) {
         Cache::forget('last_lots');
     }
     return redirect('/dashboard/auctions');
 }