diff --git a/Modules/Tag/Tests/Integration/TaggableTraitTest.php b/Modules/Tag/Tests/Integration/TaggableTraitTest.php index ccee276ea..ae219772e 100644 --- a/Modules/Tag/Tests/Integration/TaggableTraitTest.php +++ b/Modules/Tag/Tests/Integration/TaggableTraitTest.php @@ -153,6 +153,17 @@ public function it_gets_pages_with_non_latin_tags() $this->assertCount(1, Page::whereTag(['ํ•œ๊ธ€-ํƒœ๊ทธ'])->get()); } + /** @test */ + public function it_creates_page_without_tags() + { + $this->createPage(['original tag']); + + $page = $this->page->find(1); + $page->setTags(null); + + $this->assertEmpty(Page::first()->tags->count()); + } + private function createPage(array $tags = []) { return $this->page->create([ diff --git a/Modules/Tag/Traits/TaggableTrait.php b/Modules/Tag/Traits/TaggableTrait.php index 2c6df68e2..08fb9275b 100644 --- a/Modules/Tag/Traits/TaggableTrait.php +++ b/Modules/Tag/Traits/TaggableTrait.php @@ -97,6 +97,10 @@ public static function allTags() */ public function setTags($tags, $type = 'slug') { + if (empty($tags)) { + $tags = []; + } + // Get the current entity tags $entityTags = $this->tags->pluck($type)->all();