/** * Removes document. * * @return Result */ public function delete() { if ($this->hasStores() === true) { return (new Result())->setError(Result::ERROR_CANNOT_DELETE_RECORD, 'Country has related stores'); } return parent::delete(); }
/** * Deletes record from collection. * * @return Result */ public function delete() { if ($this->existsInProducts() === true) { return (new Result())->setError(Result::ERROR_CANNOT_UPDATE_RECORD, 'Vendor has related products'); } return parent::delete(); }
/** * Removes document. * * @return Result */ public function delete() { $existsInUseRoles = (bool) $this->getClient()->getCollection('User')->countByAttributes(['permissions' => ['$in' => [$this->getId()]]]); if ($existsInUseRoles) { return (new Result())->setError(Result::ERROR_CANNOT_DELETE_RECORD, 'Some users still use this role'); } return parent::delete(); }
/** * Removes document. * * @return Result */ public function delete() { $hasUnsentLetters = (bool) $this->getClient()->getCollection('Letter')->countByAttributes(['letter_template_id' => $this->getId()]); if ($hasUnsentLetters) { return (new Result())->setError(Result::ERROR_CANNOT_DELETE_RECORD, 'Template has related unsent letters'); } return parent::delete(); }
/** * Removes document. * * @return Result */ public function delete() { $existsInUnitCollection = (bool) $this->getClient()->getCollection('Unit')->countByAttributes(['measure_id' => $this->getId()]); if ($existsInUnitCollection) { return (new Result())->setError(Result::ERROR_CANNOT_DELETE_RECORD, 'Measure has related units'); } return parent::delete(); }
/** * Deletes record from collection. * * @return Result */ public function delete() { $result = new Result(); if ($this->existsInProductCharacteristics() === true) { return $result->setError(Result::ERROR_CANNOT_UPDATE_RECORD, 'Property present in product specifications'); } if ($this->existsInCategoryCollection() === true) { return $result->setError(Result::ERROR_CANNOT_UPDATE_RECORD, 'Property present in category collection'); } return parent::delete(); }