public function cariProduk() { $keyword = Input::get('term'); $barangs = Barang::where('nama', 'LIKE', '%' . $keyword . '%')->paginate(9); $categories = Category::with('barang')->get(); $bId = [1, 2, 3, 4, 83, 16, 17, 18, 9, 10, 11]; $unpublished = [36, 15, 16]; $aroma = $_POST['aroma']; return View::make('store.search', compact('barangs', 'bId', 'unpublished', 'aroma')); }
public function index() { switch ($this->type) { case 'categories': $list = Category::with('seo')->get(array('id', 'name')); break; default: $list = Product::with('seo')->get(array('id', 'name')); break; } $this->layout->content = View::make('admin.seo.list', array('type' => $this->type, 'list' => $list)); }
/** * Fetch titles via given query and attach * them to the given category. * * @param mixed $id * @param string $query * @param integer $limit * * @return Category */ public function attachByQuery($id, $query, $limit = 8) { if (isset($this->queries[$query])) { $this->detachAll($id); //get class name and method name extract($this->queries[$query]); //fetch titles via query method on the class $titles = App::make($class)->{$method}($limit); $sync = array(); foreach ($titles->lists('id') as $key => $tid) { //$sync[$tid] = array('categorizable_type' => $type); $sync[] = $tid; } //attach fetched categorizable resources to the category $this->model->find($id)->{$type}()->sync($sync); Cache::forget('home.content'); return $this->model->with(ucfirst($type))->find($id); } }
public function index() { //get imageslider $sliders = Slider::orderBy('created_at', 'desc')->take(5)->get(); //affiche le post vedette sur la home page avec la categorie prédéfinis $headliner = Category::with(['posts' => function ($query) { $query->orderBy('published_at', 'DESC')->take(1)->get(); }])->where('id', '=', '5')->get(); //show 4 categories with only one post by Category $categories = Category::with(['posts' => function ($query) { $query->orderBy('published_at', 'DESC')->take(5)->get(); }])->take(4)->get(); //Category publicite show image with publicity link $pub = Category::orderBy('created_at', 'DESC')->where('id', '=', '6')->take(1)->get(); //affichage des commentaires par posts $comments = Comment::orderBy('created_at', 'desc')->take(6)->get(); //Retrun 2 post by category check model Category twicePost $postCat = Category::with(['posts' => function ($query) { // Note that you don't have to call get() here! $query->orderBy('published_at', 'desc')->latest(); }])->take(4)->get(); return View::make('home.index')->with(array('sliders' => $sliders, 'comments' => $comments, 'categories' => $categories, 'headliner' => $headliner, 'pub' => $pub, 'postCat' => $postCat)); }
public function get_index($cat = '', $alias = '') { //Filtering the Attribute groups for product specific if (empty($alias)) { } $prod = Product::with(array('getCategory', 'getCategory.getDescriptions'))->where('alias', '=', $cat)->first(); $cat = $prod->getCategory[0]->getDescriptions->alias; $alias = $prod->alias; $category_id = CategoryDescription::with('getCategory')->where('alias', '=', $cat)->only('id'); $result = Category::with(array("getDescriptions", "getTopCat", "getTopCat.getDescriptions", "getProducts" => function ($query) use($alias) { $query->where('alias', '=', $alias); }, "getProducts.getBrand", "getProducts.getImages", "getProducts.getDetail", "getProducts.getTax", "getProducts.getDiscount", "getProducts.getAttributes", "getProducts.getShipment", "getAttributeListing", "getAttributeListing.getTopGroup"))->where('id', '=', $category_id)->first(); Title::put($result->getProducts[0]->getDetail->name); /*Get attributes*/ $topGroups = array(); foreach ($result->getAttributeListing as $item) { array_push($topGroups, $item->getTopGroup->id); } $topGroups = array_unique($topGroups); $groups = array(); foreach ($result->getAttributeListing as $item) { array_push($groups, $item->id); } $groups = array_unique($groups); $belongedGroups = array(); foreach ($result->getProducts[0]->getAttributes as $item) { array_push($belongedGroups, $item->id); } $attrs = AttributeGroup::with(array('getParentGroup' => function ($query) use($groups) { $query->order_by('sort_order', 'desc'); $query->where_in('id', $groups); }, 'getParentGroup.getAttributes' => function ($query) use($belongedGroups) { $query->where_in('id', $belongedGroups); }))->where_in('id', $topGroups)->get(); return View::make('products.index')->with('product', $result)->with('attrs', $attrs); }
public function post_getCategory() { $categoryID = Input::get('menuid'); $category = Category::with('getDescriptions')->where('parent_id', '=', $categoryID)->or_where('id', '=', $categoryID)->order_by('sort_order', 'ASC')->get(); $getPopularSubs = Category::with('getDescriptions')->where('parent_id', '=', $categoryID)->order_by('views', 'DESC')->take(9)->get(); $view = View::make('category.parent_category'); $view->categories = $category; $view->popular = $getPopularSubs; return Response::json(array('d' => $view->render())); }
if ($isTop->top == 1) { //getting the products which belongs to this category! $children = Category::with("getChildren")->where("id", "=", $var)->first(); $childrenIDS = array(); foreach ($children->getChildren as $child) { array_push($childrenIDS, $child->id); if ($child->getChildren) { foreach ($child->getChildren as $subchild) { array_push($childrenIDS, $subchild->id); } } } $result = Category::with(array("getProductsMostView4sq", "getProductsMostView4sq.getBrand", "getProductsMostView4sq.getImages", "getProductsMostView4sq.getDetail", "getProductsMostView4sq.getTax", "getProductsMostView4sq.getDiscount"))->where_in('id', $childrenIDS)->get(); } else { //getting the products which belongs to this category! $result = Category::with(array("getProductsMostView4sq", "getProductsMostView4sq.getBrand", "getProductsMostView4sq.getImages", "getProductsMostView4sq.getDetail", "getProductsMostView4sq.getTax", "getProductsMostView4sq.getDiscount"))->where('id', '=', $category_id)->first(); } } ?> <div class="row-fluid"> <div class="span12"> <div class="block-header"> <p>EN BEĞENİLEN ÜRÜNLER</p> </div> </div> <div class="row-fluid"> @foreach($result as $res) @if($res->getProductsMostView4sq) <?php $count = 0; $numItems = count($res->getProductsMostView4sq);
Route::controller(Controller::detect()); /*Route::filter('pattern: ^(?!user/login)*', 'auth');*/ Event::listen('404', function () { return Response::error('404'); }); Event::listen('500', function () { return Response::error('500'); }); Route::filter('before', function () { Check_User_Cart(); //Adding -> Assets Asset::container('styleSheet')->add('mainStyle', 'css/style.css'); Asset::container('bootstrap')->add('BootstrapJS', 'js/bootstrap.js'); Asset::container('megaMenu')->add('menu', 'js/script.js'); //Composer! $category = Category::with('getDescriptions')->where('top', '=', '1')->get(); View::share('cat', $category); if (!Cache::has('settings')) { $settings = Setting::obtain(); Cache::put('settings', $settings, 60); } $settings = Cache::get('settings'); View::share('settings', $settings); }); Route::filter('after', function ($response) { // Do stuff after every request to your application... }); Route::filter('csrf', function () { if (Request::forged()) { return Response::error('500'); }
public function get_index() { $categories = Category::with('organisations')->order_by('title', 'asc')->paginate(20); return View::make('user.categories.categories')->with('categories', $categories); }
public function one($id) { $product = Product::with('crops')->where('crop_id', '=', $id)->get(); $categories = Category::with('crops')->get(); return View::make('main.all', compact('product'))->with('categories', $categories)->with('title', "Product Details"); }
public function post_product_add() { $data = Input::all(); $sessionArr = array("name" => "", "price" => "", "attrs" => array()); $attributes = array(); //check that product model is exist! $productCheck = Product::where('model', '=', $data['p_model'])->first(); if (empty($productCheck)) { //first we fetch the brand and get the ID if (empty($data['p_brand_other'])) { $brand = $data['p_brand']; //e.g $brand = 3; } else { //here we get brand ID by brand_other's input if the brand_other is filled $brandCheck = Brand::where("name", '=', $data['p_brand_other'])->first(); if (empty($brandCheck)) { $brand = DB::table('brands')->insert_get_id(array('name' => $data['p_brand_other'], 'alias' => Str::slug($data['p_brand_other']))); } else { $brand = $brandCheck->id; } } $brandName = Brand::where("id", '=', $brand)->only('name'); $brandalias = Brand::where("id", '=', $brand)->only('alias'); $imageIDs = array(); //pic $images = $data["userfile"]; $mainImg = $data["active"]; $CategoryfurImages = Category::with('getDescriptions')->where("id", "=", $data['p_category'])->first(); for ($i = 0; $i < sizeof($images['name']); $i++) { $img = array('name' => $images['name'][$i], 'type' => $images["type"][$i], "tmp_name" => $images["tmp_name"][$i], "error" => $images["error"][$i], "size" => $images["size"][$i]); try { array_push($imageIDs, $this->imageSizer($img, $CategoryfurImages)); } catch (Exception $e) { Session::flash('status', 'Resim eklemede hata oluştu Ürünü tekrar ekleyiniz!\\r\\n' . $e->getMessage()); return Redirect::to('admin/product/new'); } } //now insert the product, first things first. $product = DB::table('products')->insert_get_id(array('brand_id' => $brand, 'model' => $data['p_model'], 'price' => ceil($data['p_price'] / 1.18), 'quantity' => $data['p_qty'], 'tax_class_id' => $data['p_tax'], 'barcode' => $data['p_barcode'], 'alias' => trim(Str::slug($brandalias . ' ' . $data['p_model'])), 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()'))); //inserting pictures for ($i = 0; $i < count($imageIDs); $i++) { $imagesSql = DB::table('product_images')->insert(array('product_id' => $product, 'main' => $mainImg[$i] == 1 ? 1 : 0, 'unique_id' => $imageIDs[$i])); } $productDescription = DB::table('product_descriptions')->insert_get_id(array('product_id' => $product, 'name' => $brandName . ' ' . $data['p_model'], 'description' => $data['p_description'], 'variant' => $data['p_variant'], 'tag' => $data['p_tag'])); $sessionArr["name"] = $brandName . ' ' . $data['p_model']; $sessionArr["price"] = ceil($data['p_price'] / 1.18); //we insert the product now we set the category where the product belong $cagetory = DB::table('map_product_category')->insert_get_id(array('product_id' => $product, 'category_id' => $data['p_category'])); $attr_other = $data['attr_other']; $attrs = array(); $check = true; foreach ($data['attr'] as $k => $v) { if (!empty($data['attr_other'][$k])) { $CheckTheAttr = Attribute::where_attribute_group_id_and_value($k, $attr_other[$k])->first(); if ($CheckTheAttr == null) { $attrotherID = DB::table('attributes')->insert_get_id(array('attribute_group_id' => $k, 'value' => $data['attr_other'][$k])); array_push($attributes, "Ekstra eklenen ve girilen ürün özelliği : " . $attr_other[$k]); $attrs[$k] = $attrotherID; } else { $attrs[$k] = $v; } } else { array_push($attributes, "Girilen ürün özelliği : " . $v); $attrs[$k] = $v; } } array_push($sessionArr["attrs"], $attributes); $attrsOrdered = array(); foreach ($attrs as $k => $v) { $attrsOrdered[] = array('product_id' => $product, 'attribute_id' => $v); } $attrs = DB::table('map_product_attribute')->insert($attrsOrdered); } else { Session::flash('status', 'Bu ürün daha önce sisteme eklenmiş!'); return Redirect::to('admin/product/new'); } return Redirect::to('admin/product/new')->with("result", $sessionArr); }
public function getById($id) { return Category::with('parent')->find($id); }
/** * Get random words * * @deprecated * @return array $words */ public function randomwords() { $return = array(); $amount = 20; foreach (Category::with('wordcards')->get() as $category) { foreach ($category->wordcards as $wordcard) { if (rand(0, 2) == 2 && !in_array($wordcard, $return) && count($return) < $amount) { array_push($return, $wordcard); } } } shuffle($return); return $this->wordTransformer->transformWords($return); }
public function eagerLoad($table, $order_by = 'id', $sort = 'asc') { return Category::with(['category_description.category_description_translations' => function ($query) { $query->orderBy('id', 'asc'); $query->where('category_description_translations.locale', '=', App::getLocale()); }])->get(); }