本文整理匯總了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();
}