/**
  * Delete Post with dates.
  * 
  * @todo: use beforeDelete for global delete all Post relations
  */
 public function deletePastDates($postId)
 {
     PostDates::deleteAll(['PostID' => $postId]);
     Posts::deleteAll(['PostID' => $postId]);
 }
 public static function deleteWish($postid)
 {
     $data = Posts::find()->where(['and', 'UserID' => \Yii::$app->user->getId(), 'PostID' => $postid])->one();
     if (isset($data->PostID)) {
         Posts::deleteAll(['PostID' => $postid]);
         PostURL::deleteAll(['PostID' => $postid]);
         // След строчки уже были в коде, можно вынести их
         $imgstodelete = PostImgs::find()->select(['PostImgID', 'PostImg'])->where(['PostID' => $postid])->all();
         if (count($imgstodelete)) {
             foreach ($imgstodelete as $img) {
                 if (isset($img->PostImgID)) {
                     unlink(Yii::getAlias('@webroot/photos/wishlist/' . \Yii::$app->user->getId() . '/' . $img->PostImgID . '-xn.jpg'));
                     unlink(Yii::getAlias('@webroot/photos/wishlist/' . \Yii::$app->user->getId() . '/' . $img->PostImgID . '-n.jpg'));
                     unlink(Yii::getAlias('@webroot/photos/wishlist/' . \Yii::$app->user->getId() . '/' . $img->PostImgID . '-s.jpg'));
                 }
             }
         }
         PostImgs::deleteAll(['PostID' => $postid]);
     }
 }