/** * Tes menambahkan Image */ public function testAdd() { $obj = new Image(); $obj->title = 'title'; $obj->slug = 'slug'; $obj->filename = 'filename'; $obj->description = 'description'; $saved = $obj->save(); $this->assertTrue($saved); $obj_2 = Image::find($obj->id); if ($obj_2 !== null) { $this->assertEquals($obj, $obj_2); } }
/** * Get posts of the image. * * @return Response */ public function getPosts($id) { $image = Image::find($id); if ($image) { $posts = $image->posts()->get(); return $posts; } throw new CrudException('image:getPosts'); }