Example #1
0
 public function updateTagsForType(string $type)
 {
     collect($this->request->get("{$type}_tags"))->each(function ($name) use($type) {
         $type = new TagType($type);
         $tag = Tag::findByNameOrCreate($name, $type);
         $this->model->tags()->attach($tag);
     });
 }
Example #2
0
 public function seedRandomTags($amount = 10)
 {
     $tags = new Collection();
     for ($i = 0; $i < $amount; ++$i) {
         $tag = Tag::findByNameOrCreate($this->faker->words(2, true), TagType::NEWS_TAG());
         $tags->add($tag);
     }
     return $tags;
 }