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


PHP Category::findBySlug方法代码示例

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


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

示例1: getBrand

 public static function getBrand($prod)
 {
     $brands = array_flatten(\App\Models\Category::findBySlug("brand-name")->getDescendants(1, ['id'])->toArray());
     $prodCats = array_flatten($prod->categories()->get(['cat_id'])->toArray());
     @($brand = array_flatten(array_intersect($brands, $prodCats))[0]);
     return $brand;
 }
开发者ID:sushilcs111,项目名称:td,代码行数:7,代码来源:Helper.php

示例2: createSlug

 public function createSlug($title, $numb = 0)
 {
     $slug = str_slug($title, '-') . ($numb ? '-' . $numb : '');
     $already = Category::findBySlug($slug);
     if ($already->count()) {
         return $this->createSlug($title, $numb + 1);
     }
     return $slug;
 }
开发者ID:amteknologi,项目名称:e-commerce,代码行数:9,代码来源:Category.php

示例3: index

 public function index($slug)
 {
     $category = Category::findBySlug($slug);
     $sizes = array_flatten(Attribute::where("attr", "Shoe Size")->first()->attributeoptions()->select('option_name')->get()->toArray());
     $parts = scandir(public_path() . "/Frontend/shoes/" . $category->folder);
     $parts = array_diff($parts, array('.', '..'));
     $savedList = User::find(Session::get('user')->id)->savedlist;
     //print_r($savedList);
     return view(Config('constants.frontView') . '.design', compact('category', 'parts', 'sizes', 'savedList'));
 }
开发者ID:sushilcs111,项目名称:td,代码行数:10,代码来源:DesignController.php

示例4: getFilters

 public function getFilters($slug)
 {
     $currentCat = Category::findBySlug($slug);
     if (!$currentCat) {
         $currentCat = Category::findBySlug("shop");
     }
     $filters = ["id" => $currentCat->id, "category" => "Categories", "child" => $currentCat->getDescendants(1, ['id', 'category'])->toHierarchy()];
     $cats = Category::roots()->where("url_key", "!=", 'shop')->where("url_key", "!=", "popular")->get()->toHierarchy();
     foreach ($cats as $cat) {
         $cat->child = $cat->getDescendants(1, ['id', 'category'])->toHierarchy();
     }
     $cats = $cats->toArray();
     array_unshift($cats, $filters);
     return response()->json($cats);
 }
开发者ID:bhavs123,项目名称:web,代码行数:15,代码来源:CategoryController.php

示例5: index

 public function index($slug = null)
 {
     $category = Category::findBySlug($slug)->first();
     $products = Product::categorized($category)->paginate(8);
     return view('admin.products.index')->with('categories', Category::tree())->with('products', $products);
 }
开发者ID:ninjamonz,项目名称:laravel_catalog_example,代码行数:6,代码来源:ProductsController.php

示例6: getNewProds

 public function getNewProds()
 {
     $products = Product::where("is_individual", 1)->orderBy("id", "desc")->paginate(8);
     foreach ($products as $prd) {
         $attrs = [];
         foreach ($prd->categories()->where("url_key", "!=", "popular")->get() as $cat) {
             $pcat = $cat->getAncestors()->toArray();
             $attrs[$pcat[0]['category']] = $cat->category;
         }
         $prd->tags = $prd->tagged;
         $prd->attrs = $attrs;
         $prd->image = $prd->catalogimgs()->first();
         @($prd->image->filename = asset(Config('constants.productImgPath') . @$prd->image->filename));
         if (Session::get("userId") && User::find(Session::get("userId"))->savedlist->contains($prd->id)) {
             $prd->saved = 1;
         } else {
             $prd->saved = 0;
         }
     }
     $products = $products->toArray();
     $products['maincat'] = Category::findBySlug("popular")->category;
     return response()->json($products);
 }
开发者ID:bhavs123,项目名称:web,代码行数:23,代码来源:ProductController.php

示例7: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $cat = Category::findBySlug($slug);
     $pages = $cat->pages()->paginate(10);
 }
开发者ID:danielchikaka,项目名称:osh,代码行数:11,代码来源:CategoriesController.php


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