本文整理汇总了PHP中app\Category::whereDepth方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::whereDepth方法的具体用法?PHP Category::whereDepth怎么用?PHP Category::whereDepth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::whereDepth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: categories
public function categories()
{
$view = Input::get('view');
if ($view == null) {
return redirect('/admin/categories?view=hierarchy');
}
$levels = ['Main Category', 'Subcategory', 'Post Sub Category'];
$types = ['main-categories', 'sub-categories', 'post-sub-categories'];
$views = ['Hierarchy', 'Type', 'All'];
$cats = Category::roots()->get();
$category = Input::get('category');
$_category = Category::find($category);
if ($view == 'type') {
$type = Input::get('type');
if ($type == null) {
$type = $types[0];
}
// array_keys() = get keys from value
// appends() = add 'get' variables (to url)
$cats = Category::whereDepth(array_keys($types, $type))->paginate(25)->appends(Input::except('page'));
} else {
if ($view == 'all') {
$cats = Category::paginate(25)->appends(Input::except('page'));
}
}
return view('admin.main')->with('category', $_category)->with('cats', $cats)->with('levels', $levels)->with('view', $view)->with('views', $views)->with('types', $types);
// only for 'type' view
}
示例2: getSubCatSet
public function getSubCatSet()
{
$catarray = [];
$cats = Category::whereDepth(1)->get();
$counter = 0;
for ($col = 0; $col < 3; $col++) {
$fillmore = true;
$row = 0;
$colarray = [];
while ($fillmore) {
if (isset($cats[$counter])) {
$colarray[$row] = ['id' => $cats[$counter]->id, 'name' => $cats[$counter]->name];
} else {
break;
}
$row++;
$counter++;
if ($row > 11) {
$fillmore = false;
}
}
$catarray[$col] = $colarray;
}
return $catarray;
}
示例3: __construct
public function __construct()
{
// $productQuery = Globex::with('images')->select('id', 'title', 'description', 'price', DB::raw('0 as type'));
// $adQuery = Advertisement::with('images')->select('id', 'title', 'description','price', DB::raw('1 as type'));
// $motorQuery = Motor::with('images')->select('id', 'title', 'description','price', DB::raw('2 as type'));
// $this->products = $adQuery->get()->merge($productQuery->get())->merge($motorQuery->get());
$this->products = Product::with('producible')->get();
$this->emirates = Emirate::all();
$this->cats = Category::whereDepth(0)->get();
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$data = ['myads' => Auth::customer()->get()->advertisements, 'cats' => Category::whereDepth(2)->lists('name', 'id')];
return view('pages.myads', $data);
}
示例5: getSubCats
public function getSubCats()
{
return Category::whereDepth(1)->get();
}