示例#1
0
 public function map(EntityContract $entity, array $data)
 {
     $entity->setPosts(function () use($data) {
         return $this->postRepository->postsInCategory($data['term_id']);
     });
     $id = $data['parent'];
     $entity->setParentId($id);
     $entity->setParent(function () use($id) {
         $parent = null;
         if ($id) {
             $parent = $this->categoryRepository->categoryOfId($id);
         }
         return $parent;
     });
 }