Exemplo n.º 1
0
 /**
  * 휴지통에서 문서 복원
  *
  * @param Board        $board  board model
  * @param ConfigEntity $config board config entity
  * @return void
  */
 public function restore(Board $board, ConfigEntity $config)
 {
     $board->getConnection()->beginTransaction();
     // 덧글이 있다면 덧글들을 모두 복원
     if ($config->get('recursiveDelete') === true) {
         $query = Board::where('head', $board->head);
         if ($board->reply !== '' && $board->reply !== null) {
             $query->where('reply', 'like', $board->reply . '%');
         }
         $items = $query->get();
         foreach ($items as $item) {
             $this->setModelConfig($item, $config);
             $item->setRestore()->save();
         }
     } else {
         $board->setRestore()->save();
     }
     $board->getConnection()->commit();
 }