Ejemplo n.º 1
0
 /**
  * @param $id
  * @return \Illuminate\Contracts\View\View
  */
 public function show($id)
 {
     $category = new Category($id);
     $this->events->fire(new OnCategoryShow($this->app, $this->view, $category->getModel()));
     $this->seo->setTitleMeta($category->getTitle() . ' - {sitename}');
     $this->seo->setDescriptionMeta($category->getDescription());
     $this->seo->setKeywordsMeta($category->getKeywords());
     $this->share('category', $category->getModel());
     $this->share('name', $category->getTitle());
     $this->share('list', $category->getList());
     $this->share('relations', $category->getRelationCategoryList());
     return $this->view($category->getShowTemplate());
 }
 /**
  * @return void
  */
 public function boot()
 {
     $this->getEvents()->listen('router.before', function () {
         $categories = CategoryModel::whereEnabled(true)->get();
         foreach ($categories as $value) {
             if ($value->alias) {
                 $category = new Category($value->id);
                 $this->getRouter()->get($category->getRouting() . '/{id}', 'Notadd\\Article\\Controllers\\ArticleController@show')->where('id', '[0-9]+');
                 $this->getRouter()->get($category->getRouting(), function () use($category) {
                     return $this->app->call('Notadd\\Category\\Controllers\\CategoryController@show', ['id' => $category->getId()]);
                 });
             }
         }
     });
     $this->getRouter()->group(['namespace' => 'Notadd\\Category\\Controllers'], function () {
         $this->getRouter()->group(['middleware' => 'auth.admin', 'namespace' => 'Admin', 'prefix' => 'admin'], function () {
             $this->getRouter()->resource('category', 'CategoryController');
             $this->getRouter()->post('category/{id}/status', 'CategoryController@status');
         });
         $this->getRouter()->resource('category', 'CategoryController');
     });
     $this->getEvents()->subscribe(BeforeCategoryDelete::class);
 }
Ejemplo n.º 3
0
 /**
  * @return string
  */
 public function getRouting()
 {
     $category = new Category($this->model->getAttribute('category_id'));
     $path = $category->getRouting();
     return $path . '/' . $this->id;
 }