当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::with方法代码示例

本文整理汇总了PHP中Category::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::with方法的具体用法?PHP Category::with怎么用?PHP Category::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::with方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cariProduk

 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'));
 }
开发者ID:shittyc0de,项目名称:AplikasiLC,代码行数:10,代码来源:StoreController.php

示例2: index

 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));
 }
开发者ID:basuritas-laravel,项目名称:laravel-seo,代码行数:12,代码来源:SeoController.php

示例3: attachByQuery

 /**
  * 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);
     }
 }
开发者ID:onlystar1991,项目名称:mtdb,代码行数:29,代码来源:CategoriesRepository.php

示例4: index

 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));
 }
开发者ID:uknowcreation,项目名称:laravelblog,代码行数:23,代码来源:HomeController.php

示例5: get_index

 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);
 }
开发者ID:TahsinGokalp,项目名称:L3-Eticaret,代码行数:36,代码来源:product.php

示例6: post_getCategory

 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()));
 }
开发者ID:TahsinGokalp,项目名称:L3-Eticaret,代码行数:10,代码来源:category.php

示例7: array

    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);
开发者ID:TahsinGokalp,项目名称:L3-Eticaret,代码行数:31,代码来源:mostviewedproducts4sq.blade.php

示例8: function

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');
    }
开发者ID:CSFix,项目名称:L3-Eticaret,代码行数:31,代码来源:routes.php

示例9: get_index

 public function get_index()
 {
     $categories = Category::with('organisations')->order_by('title', 'asc')->paginate(20);
     return View::make('user.categories.categories')->with('categories', $categories);
 }
开发者ID:shainmcalindon,项目名称:boothsgardenstudios,代码行数:5,代码来源:categories.php

示例10: one

 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");
 }
开发者ID:talha08,项目名称:Farmer-Bazar,代码行数:6,代码来源:ProductsController.php

示例11: post_product_add

 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);
 }
开发者ID:TahsinGokalp,项目名称:L3-Eticaret,代码行数:78,代码来源:admin.php

示例12: getById

 public function getById($id)
 {
     return Category::with('parent')->find($id);
 }
开发者ID:eragon011,项目名称:kwanphayao,代码行数:4,代码来源:CategoryService.php

示例13: randomwords

 /**
  * 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);
 }
开发者ID:SenhorBardell,项目名称:wordotheday,代码行数:20,代码来源:WordCardsController.php

示例14: eagerLoad

 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();
 }
开发者ID:mikimaine,项目名称:ecommerce,代码行数:7,代码来源:EloquentProductRepository.php


注:本文中的Category::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。