Exemplo n.º 1
0
 /**
  * Handle the command.
  *
  * @param  UpdateTagCommand  $command
  * @return void
  */
 public function handle(UpdateTagCommand $command)
 {
     $active = 1;
     // $active = ($command->active === 'on') ? 1 : 0;
     $category_object = Tags::edit($command->tag_id, $command->tag, $active);
     $tag = $this->repo->save($category_object);
     Event::fire(new TagWasUpdated($tag));
     return $tag;
 }
Exemplo n.º 2
0
 /**
  * Handle the command.
  *
  * @param  CreateTagCommand  $command
  * @return void
  */
 public function handle(CreateTagCommand $command)
 {
     $active = 1;
     // $active = ($command->active === 'on') ? 1 : 0;
     $tag_object = Tags::make($command->tag, $active);
     $tag = $this->repo->save($tag_object);
     Event::fire(new TagWasCreated($tag));
     return $tag;
 }
Exemplo n.º 3
0
 public function getRelatedNewsByCategoryAndTags(Pages $page)
 {
     $category_ids = array_pluck($page->categories, 'id');
     $tag_ids = array_pluck($page->tags, 'id');
     if (count($category_ids) < 1) {
         $category_ids = [''];
     }
     if (count($tag_ids) < 1) {
         $tag_ids = [''];
     }
     $category_news = array_pluck(Categories::with('news.categories', 'news.tags')->whereIn('id', $category_ids)->get(), 'news');
     $tag_news = array_pluck(Tags::with('news.categories', 'news.tags')->whereIn('id', $tag_ids)->get(), 'news');
     if (count($category_news)) {
         $category_news = $category_news[0];
     }
     if (count($tag_news)) {
         $tag_news = $tag_news[0];
     }
     return array($category_news, $tag_news);
 }
Exemplo n.º 4
0
 public function getBySlug($slug)
 {
     return Tags::with('news')->where('slug', $slug)->first();
 }