Esempio n. 1
0
 public function testMergeIntoSelf()
 {
     $tag = Tag::firstOrCreate(['name' => 'Tag 1']);
     $this->assertSame(1, Tag::count());
     $tag->merge($tag);
     $this->assertSame(1, Tag::count());
 }
Esempio n. 2
0
 /**
  * Add some new tags by ajax.
  *
  * @param Request $request
  */
 public function ajaxAddTags(Request $request)
 {
     $newTags = $request->input('new_tags', []);
     foreach ($newTags as $newTag) {
         $tag = Tag::firstOrCreate(['name' => $newTag]);
     }
     echo "添加成功!";
 }