Beispiel #1
0
 /**
  * Tes menambahkan Tag
  */
 public function testAdd()
 {
     $obj = new Tag();
     $obj->title = 'Title Unimportant';
     $saved = $obj->save();
     $this->assertTrue($saved);
     $obj_2 = Tag::find($obj->id);
     if ($obj_2 !== null) {
         $this->assertEquals($obj, $obj_2);
     }
     // testing slug already exist
     $obj_3 = new Tag();
     $obj_3->title = 'Title Unimportant';
     $saved = $obj_3->save();
     $this->assertTrue($saved);
     $this->assertEquals('title-unimportant-new', $obj_3->slug);
     // testing slug already exist #2
     $obj_3 = new Tag();
     $obj_3->title = 'Title Unimportant';
     $saved = $obj_3->save();
     $this->assertTrue($saved);
     $this->assertEquals('title-unimportant-new-new', $obj_3->slug);
 }
Beispiel #2
0
 /**
  * Get posts of the tag.
  *
  * @return Response
  */
 public function getPosts($id)
 {
     $tag = Tag::find($id);
     if ($tag) {
         $posts = $tag->posts()->get();
         return $posts;
     }
     throw new CrudException('tag:getPosts');
 }