本文整理汇总了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;
}
示例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;
}
示例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'));
}
示例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);
}
示例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);
}
示例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);
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($slug)
{
$cat = Category::findBySlug($slug);
$pages = $cat->pages()->paginate(10);
}