/** * {@inheritDoc} */ public function addTag($tag) { if ($tag instanceof Tag) { return $this->addTag($tag->getName()); } try { return $this->tags()->updateExistingPivot($this->getTag($tag)->getId()); } catch (TagNotFoundException $e) { $relation = Tag::whereName($tag)->first(); if (is_null($relation)) { $relation = Tag::create(array('name' => $tag)); } return $this->tags()->attach($relation); } }
public function testOrderAttributeIsFillable() { $t = new Tag(array('order' => 10)); $this->assertEquals(10, $t->getOrder()); }
public function testNameAttributeIsFillable() { $t = new Tag(array('name' => 'Test')); $this->assertEquals('Test', $t->getName()); }