<div class="col-xs-12 col-md-6"> <div class="form-group @if($errors->has('lot_title'))has-error @endif"> <label for="lot_title">Назва лоту <span class="label-required">*</span></label> <input type="text" name="lot_title" class="form-control input-lg" id="lot_title" placeholder="" value="{{{ old('lot_title') }}}"> </div> </div> <div class="col-xs-12 col-md-6"> <div class="form-group @if($errors->has('lot_category'))has-error @endif"> <label for="lot_category">Категорія лоту <span class="label-required">*</span></label> <select id="SelectCategory" class="form-control input-lg" name="lot_category"> <option value>Не обрано</option> <?php $cats = \App\Cat::roots()->get(); ?> @foreach($cats as $category) <option @if(old('lot_category') == $category->id)selected @endif value="{{ $category->id }}">{{ $category->name }}</option> @endforeach </select> </div> </div> </div> <div class="row load_children" style="display: none"> <div class="col-xs-12"> <div class="form-group @if($errors->has('lot_type'))has-error @endif"> <div id="loadChildren"></div> </div>
/** * Display a listing of the resource. * * @return Response */ public function index($id, Request $request) { $auctions = Auction::query(); $auctions = $auctions->where('category', '=', $id); $auctions = $auctions->where('status', '>', 0); if ($request->sortBy == 'lowcost') { $auctions = $auctions->orderBy('starting_price', 'asc'); } elseif ($request->sortBy == 'topcost') { $auctions = $auctions->orderBy('starting_price', 'desc'); } elseif ($request->sortBy == 'new') { $auctions = $auctions->orderBy('created_at', 'desc'); } elseif ($request->sortBy == 'new') { $auctions = $auctions->orderBy('created_at', 'desc'); } else { $request->sortBy = 'new'; $auctions = $auctions->orderBy('created_at', 'desc'); } if ($request->items_per_page) { $auctions = $auctions->paginate($request->items_per_page); } else { $auctions = $auctions->paginate(10); } $categories = Cat::roots()->get(); $currentCategory = Cat::find($id); return view('auction.categories.index', ['auctions' => $auctions, 'categories' => $categories, 'currentCategory' => $currentCategory, 'request' => $request]); }
/** * Отображает страницу с картой сайта * */ public function getSitemapPage(Request $request) { $cats = Cache::remember('cats', 10, function () { return Cat::roots()->get(); }); $pages = Pages::all(); $news = Cache::remember('news_sitemap', 3600, function () { $news = News::where('date_publish', '<=', Carbon::parse(Carbon::now())->format('Y-m-d H:i'))->where('category', '=', 0)->get(); return $news; }); $ogoloshenia = News::where('date_publish', '<=', Carbon::parse(Carbon::now())->format('Y-m-d H:i'))->where('category', '=', 1)->get(); return view('auction.sitemap', ['categories' => $cats, 'currentCategory' => null, 'request' => $request, 'pages' => $pages, 'news' => $news, 'ogoloshenia' => $ogoloshenia]); }
/** * Обрабатываем стандартный и расширенный поиск для категории "Техника и мебель" */ public function getStuffQuery(Request $request) { $auctions = Auction::query(); $auctions = $auctions->where('category', '=', $request->category); if ($request->lot_type) { $auctions = $auctions->where('lot_type', '=', $request->lot_type); } if ($request->region) { $auctions = $auctions->where('region', '=', $request->region); } if ($request->title) { $auctions = $auctions->where('title', 'like', '%' . $request->title . '%')->orWhere('id', '=', $request->title); } if ($request->city) { $auctions = $auctions->where('city', 'like', '%' . $request->city . '%'); } if ($request->lot_DebtorName) { $auctions = $auctions->where('lot_DebtorName', 'like', '%' . $request->lot_DebtorName . '%'); } if ($request->lot_EDRPOU) { $auctions = $auctions->where('lot_EDRPOU', '=', $request->lot_EDRPOU); } if ($request->property_type) { $auctions = $auctions->whereIn('property_type', $request->property_type); } if ($request->price_from) { $auctions = $auctions->where('starting_price', '<=', $request->price_from); } if ($request->price_to) { $auctions = $auctions->where('starting_price', '<=', $request->price_to); } if ($request->date_start) { $auctions = $auctions->where('data_start', '>=', Carbon::parse($request->date_start)->format('Y-m-d')); } if ($request->date_end) { $auctions = $auctions->where('date_end', '<=', Carbon::parse($request->date_end)->format('Y-m-d')); } if ($request->lot_number) { $auctions = $auctions->where('id', '=', $request->lot_number); } if ($request->lot_user) { $searchTerms = explode(' ', $request->lot_user); $query = User::query(); foreach ($searchTerms as $searchTerm) { $query->where(function ($q) use($searchTerm) { $q->where('first_name', 'like', '%' . $searchTerm . '%')->orWhere('last_name', 'like', '%' . $searchTerm . '%')->orWhere('legal_entity', 'like', '%' . $searchTerm . '%'); }); } $users = $query->get(); // Массив для ID обнаруженных пользователей $users_id = []; // Если есть пользователи, соответствующие запросу if ($users->count() > 0) { // Перебираем каждого пользователя foreach ($users as $user) { // Добавляем ID пользователя в массив $users_id array_push($users_id, $user->id); } } // Применяем фильтрацию по совпадению с ID в массиве $users_id $auctions = $auctions->whereIn('user', $users_id); } if ($request->stuff_brand) { $auctions = $auctions->where('stuff_brand', '=', $request->stuff_brand); } if ($request->stuff_model) { $auctions = $auctions->where('stuff_model', '=', $request->stuff_model); } if ($request->stuff_year) { $auctions = $auctions->where('stuff_year', '=', $request->stuff_year); } if ($request->stuff_diagonal) { $auctions = $auctions->where('stuff_diagonal', '=', $request->stuff_diagonal); } $auctions = $auctions->paginate(10); $categories = Cat::roots()->get(); $currentCategory = Cat::find($request->category); return view('auction.search', ['auctions' => $auctions, 'categories' => $categories, 'currentCategory' => $currentCategory, 'request' => $request]); }