public function testAcceptsArrayOfTagIds() { $args = [[1, 2], ['1', '2']]; foreach ($args as $a) { $tag = new TagModel(); $tag->id = 1; TagFacade::shouldReceive('find')->once()->with($a[1])->andReturn($tag); TagFacade::shouldReceive('find')->once()->with($a[0])->andReturn($tag); $filter = new Tag($a); $this->assertTrue($filter->shouldBeApplied()); } }
/** * @param Page $page */ public function view(Site $site, Page $page) { $this->auth($page); $all = TagFacade::findBySite($site); $grouped = []; foreach ($all as $t) { $group = $t->getGroup() ?: ''; $grouped[$group][] = $t; } $tags = Helpers::getTags($page)->map(function (Tag $tag) { return $tag->getId(); }); return view('boomcms::editor.page.settings.tags', ['all' => $grouped, 'tags' => $tags->toArray()]); }
/** * @param array|TagInterface $tags */ public function __construct($tags) { if (!is_array($tags)) { $tags = [$tags]; } foreach ($tags as $i => $tag) { if (is_int($tag) || ctype_digit($tag)) { $tags[$i] = $tag = TagFacade::find($tag); } if (!$tag instanceof TagInterface || !$tag->getId()) { unset($tags[$i]); } } $this->tags = $tags; }
public function remove() { $tag = Tag::byId($this->request->input('tag')); $this->page->removeTag($tag); Event::fire(new PageHadTagRemoved($this->page, $tag)); }