Unverified Commit 4c30c451 authored by Nicolas Widart's avatar Nicolas Widart Committed by GitHub

Merge pull request #518 from Fisiu/allow_empty_tags

Set tags only if passed any.
parents 22ccee98 52d278af
......@@ -153,6 +153,17 @@ class TaggableTraitTest extends BaseTestCase
$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([
......
......@@ -97,6 +97,10 @@ trait TaggableTrait
*/
public function setTags($tags, $type = 'slug')
{
if (empty($tags)) {
$tags = [];
}
// Get the current entity tags
$entityTags = $this->tags->pluck($type)->all();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment