/** * @inheritdoc */ public function beforeDelete() { if (parent::beforeDelete()) { // Delete relation with Forms Form::updateAll(['theme_id' => null], ['theme_id' => $this->id]); return true; } else { return false; } }