本文整理汇总了PHP中app\models\Category::whereNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::whereNull方法的具体用法?PHP Category::whereNull怎么用?PHP Category::whereNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Category
的用法示例。
在下文中一共展示了Category::whereNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$data = Category::whereNull('deleted_at')->get()->toArray();
$res = new Tree($data);
return view('admin.cate.index')->with('tree', $res->getTree());
}
示例2: edit
public function edit($id)
{
$art = Article::findOrFail($id);
$cate = Category::whereNull('deleted_at')->get();
return view('admin.article.edit')->with('article', $art)->with('hotTag', $this->hotTag())->with('category', $cate);
}
示例3: showCategories
public function showCategories()
{
$categories = Category::whereNull('parent_id')->with(['children' => function ($query) {
$query->with(['children'])->orderBy('name', 'asc');
}])->orderBy('name', 'asc')->get();
/*
$categories = Category::whereNull('parent_id')->with(['children' => function($query)
{
$query->with(['children' => function($query2)
{
$query2->orderBy('name', 'asc')->get();
}])->orderBy('name', 'asc');
}])->orderBy('name', 'asc')->get();
*/
//dd($categories);
//DB::select('SELECT id, name, parent_id FROM food_categories ')
return view('admin.categories')->with(['categories' => $categories]);
}