Skip to content

Commit 4c30c45

Browse files
authored
Merge pull request #518 from Fisiu/allow_empty_tags
Set tags only if passed any.
2 parents 22ccee9 + 52d278a commit 4c30c45

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Modules/Tag/Tests/Integration/TaggableTraitTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ public function it_gets_pages_with_non_latin_tags()
153153
$this->assertCount(1, Page::whereTag(['한글-태그'])->get());
154154
}
155155

156+
/** @test */
157+
public function it_creates_page_without_tags()
158+
{
159+
$this->createPage(['original tag']);
160+
161+
$page = $this->page->find(1);
162+
$page->setTags(null);
163+
164+
$this->assertEmpty(Page::first()->tags->count());
165+
}
166+
156167
private function createPage(array $tags = [])
157168
{
158169
return $this->page->create([

Modules/Tag/Traits/TaggableTrait.php

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public static function allTags()
9797
*/
9898
public function setTags($tags, $type = 'slug')
9999
{
100+
if (empty($tags)) {
101+
$tags = [];
102+
}
103+
100104
// Get the current entity tags
101105
$entityTags = $this->tags->pluck($type)->all();
102106

0 commit comments

Comments
 (0)