/**
  * @param Category $except
  *
  * @return CategoriesController
  */
 protected function getCategoryOptions($except = null)
 {
     /** @var \Kalnoy\Nestedset\QueryBuilder $query */
     $query = CommunityCategory::select('id', 'category_name')->withDepth();
     if ($except) {
         $query->whereNotDescendantOf($except)->where('id', '<>', $except->id);
     }
     return $this->makeOptions($query->get());
 }
Exemple #2
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $currentRoute = Route::currentRouteName();
     //查询分类
     $articleCategory = ArticleCategory::all()->toTree();
     //社区分类
     $communityCategory = CommunityCategory::all()->toTree();
     //查询配置项
     $settings = Settings::all();
     foreach ($settings as $key => $value) {
         $options[$value['name']] = $value['value'];
     }
     //查询登录用户
     $user = Auth::guard('web')->user();
     $view->with('loginUser', $user)->with('currentRoute', $currentRoute)->with('articleCategory', $articleCategory)->with('communityCategory', $communityCategory)->with($options);
 }