/** * @return mixed */ protected function beforeDelete() { if (isset($_GET['id'])) { $id = $_GET['id']; } $path = $_SERVER['DOCUMENT_ROOT'] . self::model()->findByPk($id)->image; if (is_file($path)) { unlink($path); } return parent::beforeDelete(); }