Exemplo n.º 1
0
 /**
  * @test
  */
 public function delete_tag()
 {
     $tag = Tag::create(['name' => '9 Ball']);
     $this->assertEquals(1, Tag::count());
     $tag->delete();
     $this->assertEquals(0, Tag::count());
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function add_new_tag()
 {
     $this->post->tag('new TaG');
     $this->assertEquals('new tag', $this->post->tagNames);
     $this->assertEquals(['new tag'], $this->post->tagArray);
     $this->assertEquals(1, $this->post->tags->count());
     $this->assertEquals(4, Tag::count());
 }
Exemplo n.º 3
0
 /**
  *  Removes the given tags from the model.
  *
  *  @param mixed $tagNames  Array or comma separated list of tags to apply to the model.
  */
 public function untag($tagNames)
 {
     $tagNames = collect(is_array($tagNames) ? $tagNames : explode(',', $tagNames))->map(function ($tagName) {
         return Tag::normalizeTagName($tagName);
     })->toArray();
     $tags = app(TagInterface::class)->whereIn('name', $tagNames)->get()->pluck('id')->toArray();
     $this->tags()->detach($tags);
     return $this->load('tags');
 }
Exemplo n.º 4
0
 /**
  *  Mutator for the name attribute
  *
  *  @param  string $value
  *  @return void
  */
 public function setNameAttribute($value)
 {
     $this->attributes['name'] = Tag::normalizeTagName($value);
 }