static function modifiedData($input) { $item = Items::where('id', '=', $input['id'])->get()->first(); $text = ''; if ($item) { $text = $item->text; } if ($input && isset($input['obj']) && $input['obj']) { $obj = json_decode($input['obj'], true); $mark = isset($obj['type_auto'][0]['children'][0]['text']) ? $obj['type_auto'][0]['children'][0]['text'] : ''; $model = isset($obj['type_auto'][0]['children'][0]['children'][0]['text']) ? $obj['type_auto'][0]['children'][0]['children'][0]['text'] : ''; $god = isset($obj['God_vypuska'][0]['text']) ? $obj['God_vypuska'][0]['text'] : '' . 'г.'; $toplivo = isset($obj['Тип двигателя'][0]['text']) ? $obj['Тип двигателя'][0]['text'] : ''; if (isset($input['price'])) { $input['price'] = intval($input['price']); $price = "Цена {$input['price']}\$"; } else { $price = ''; } $price = isset($input['price']) ? "Цена {$input['price']}\$" : ''; if (isset($input['title']) && $input['title'] == '') { $input['title'] = "Купить {$mark} {$model} {$god} {$toplivo} {$price} в Минске Голденмоторс"; } if (isset($input['description']) && $input['description'] == '') { $input['description'] = "Продажа в РБ {$mark} {$model} {$text}"; } if (isset($input['keywords']) && $input['keywords'] == '') { $input['keywords'] = "{$mark} {$model}"; } } return $input; }
public function index($id = 0) { //get rundom category if ($id == 0) { $category = Categories::where('parent_id', '!=', 0)->orderBy(DB::raw('RAND()'))->take(1)->get(); $id = $category[0]->id; } //get all categories for menu $categories = Categories::all(); $categories = $categories->sortBy('sort_id'); //get categories for slider $sliders = Categories::where('parent_id', '!=', 0)->orderBy(DB::raw('RAND()'))->take(3)->get(); //get items $items = Items::where('categories_id', '=', $id)->get(); $data = ['categories' => $categories, 'items' => $items, 'id' => $id, 'sliders' => $sliders]; return view('categories.index', $data); }
/** * Retourne un tableau des enchères en cours * * @param Request $request * @return $this */ public function index(Request $request) { // Pagination de 30 enchères par page $items = Items::where('date_start', '<=', date('Y-m-d'))->where('date_end', '>', date('Y-m-d'))->with('category', 'user', 'bids')->paginate(20); $items->setPath('/chaudron/items'); foreach ($items as $item) { $bids = $item->bids(); // On récupère soit le montant de la dernière enchère, soit le montant initial de l'annonce $item->lastBidPrice = $item->getPrice(); // Détermine si l'utilisateur connecté est le vendeur de l'annonce $item->userIsSeller = $item->isSeller(); // Compte le nombre de propositions de l'utilisateur sur l'enchère $item->userBidsCount = $item->getUserBidsCount(); // L'utilisateur sera incapable de renchérir s'il a dépassé le montant maximum d'essais par vente $item->userCantBid = Auth::Check() && $item->userBidsCount >= MAX_BID_PER_SALE; // Prix minimum de la prochaine renchère (rajouter 0,01 € serait abusé...) $item->minBidPrice = $item->lastBidPrice + 1; // Identifiant du formulaire, utile pour mettre en évidence le formulaire où une erreur s'est produite $item->formId = 'form_' . $item->id; $item->dateDifference = $item->getDateDiff(); } return view('items')->with('items', $items); //->with('sortOptionsDefinitions', $this->sortOptionsDefinitions); }
public function ShowSubCategoryItems($id) { $data['slider'] = Slide::orderBy('created_at', 'asc')->get(); $data['sideslider'] = SideSlider::orderBy('created_at', 'asc')->get(); $data['partner'] = Partner::orderBy('created_at', 'asc')->get(); $data['category'] = Category::with('SubCategory')->orderBy('created_at', 'asc')->get(); $data['categoryex'] = Category::findOrFail($id); $data['categoryex'] = Category::with('SubCategory')->findOrFail($id); $data['subcategory'] = SubCategory::findOrFail($id); $data['item'] = Items::where('subcategory_id', $id)->orderBy('created_at', 'asc')->paginate(12); return view('site.category-item-list', $data); }
/** * Permet de récupérer plus simplement les annonces qui viennent de se terminer * * @return mixed */ public function getItemsToHandle() { return Items::where('date_end', '<=', date('Y-m-d'))->with('user', 'bids')->get(); }
/** * Update details for the item. * * @author Sinthujan G. * @return mixed Redirects to view with Error or Success messages. */ public function upPrices() { $dets = array('itName' => Request::input('iName'), 'itDescrip' => Request::input('iDescrip'), 'itPrice' => Request::input('iPrice')); $rules = array('itName' => 'required', 'itDescrip' => 'required', 'itPrice' => 'required|numeric'); $messages = array('itName.required' => 'The item name is required.', 'itDescrip.required' => 'The item description is required.', 'itPrice.required' => 'The item price is required.', 'itPrice.numeric' => 'The item price must be numeric.'); // doing the validation, passing post data, rules and the messages $validator = Validator::make($dets, $rules, $messages); if ($validator->fails()) { // send back to the page with the input data and errors return Redirect::to('aitem')->withInput()->withErrors($validator); } else { $itID = DB::table('items')->select('itID')->where('itName', '=', $dets['itName'])->first(); $chkList = DB::table('itemorders')->join('orders', 'orders.ordID', '=', 'itemorders.ordID')->join('users', 'orders.custID', '=', 'users.email')->where('itemorders.itID', '=', $itID->itID)->where('orders.status', '=', 'Ongoing')->count(); if ($chkList > 0) { return Redirect::to('aitem')->withInput()->withErrors("This item is currently in order. Please update after the order has been completed."); } else { $res = Items::where('itName', '=', $dets['itName']); $res->update($dets); } if (!$res) { App::abort(500, 'Some Error'); } return Redirect::to('aitem')->with('success', true)->with('message', 'Item sucessfully updated'); } }
function search_items(Request $request) { $s_item = $request->search_item; $items = Items::where('title', 'like', '%' . $s_item . '%')->paginate(10); return view('manage-items', ['items' => $items]); }