article = $article; $this->category = $category; } /** * Returns count of article. * * @param array $filter * * @return int */ public function count() { return 0; } /** * Make gadget View * * @param string $view * * @param int $count * * @return View */ public function gadget($view = 'admin.article.gadget', $count = 10) { if (User::hasRole('user')) { $this->article->pushCriteria(new \Litepie\Cms\Repositories\Criteria\ArticleUserCriteria()); } $article = $this->article->scopeQuery(function ($query) use ($count) { return $query->orderBy('id', 'DESC')->take($count); })->all(); return view('article::' . $view, compact('article'))->render(); } /** * Make gadget View * * @param string $view * * @param int $count * * @return View */ public function gadget($view = 'admin.category.gadget', $count = 10) { if (User::hasRole('user')) { $this->category->pushCriteria(new \Litepie\Cms\Repositories\Criteria\CategoryUserCriteria()); } $category = $this->category->scopeQuery(function ($query) use ($count) { return $query->orderBy('id', 'DESC')->take($count); })->all(); return view('article::' . $view, compact('category'))->render(); } }