/**
  * Delete records from table and related data
  *
  * @param $field
  * @param $value
  * @return bool
  */
 public function deleteByField($field, $value = null)
 {
     if (is_array($field)) {
         $items = $this->getByField($field, $this->id);
     } else {
         $items = $this->getByField($field, $value, $this->id);
     }
     $res = false;
     if ($post_ids = array_keys($items)) {
         /**
          * @event post_predelete
          * @param array[] int $post_ids array of post's ID
          * @return void
          */
         wa()->event('post_predelete', $post_ids);
         $res = parent::deleteByField('id', $post_ids);
         if ($res) {
             $comment_model = new blogCommentModel();
             $comment_model->deleteByField('post_id', $post_ids);
             $params_model = new blogPostParamsModel();
             $params_model->deleteByField('post_id', $post_ids);
             $blog_model = new blogBlogModel();
             $blogs = array();
             foreach ($items as $item) {
                 $blogs[] = $item['blog_id'];
             }
             $blogs = array_unique($blogs);
             $blog_model->recalculate($blogs);
             /**
              * @event post_delete
              * @param array[] int $post_ids array of post's ID
              * @return void
              */
             wa()->event('post_delete', $post_ids);
         }
     }
     return $res;
 }