deleteAttachedFile(); return true; } return false; } public function rules() { return [ [['archived_at'], 'integer'], [ [ 'sent_at', 'agreement_id', ], 'integer' ], [ [ 'file', 'agreement_id', ], 'required' ], [ ['archive'], 'boolean' ], [ ['file'], 'file', 'extensions' => static::getExtensionsListForRules(), 'skipOnEmpty' => true, 'maxSize' => iniGet::getUploadMaxFilesize(false), ], ]; } public static function getExtensionsListForRules(): string { return implode(', ', static::getExtensionsList()); } public static function getExtensionsList(): array { return FilesWorker::getAllowedExtensionsToUploadList(); } public function getAgreement() { return $this->hasOne(AdmissionAgreement::class, ['id' => 'agreement_id']); } protected function getOwnerId() { return isset($this->agreement->user) ? $this->agreement->user->id : $this->agreementToDelete->user_id; } public function checkAccess($user) { if ($user->isModer()) { return true; } elseif ($user->id == $this->getOwnerId()) { return true; } else { return false; } } public function getAgreementToDelete() { return $this->hasOne(AdmissionAgreementToDelete::class, ['agreement_id' => 'id']) ->viaTable('{{%admission_agreement}}', ['id' => 'agreement_id']); } public function getClassTypeForChangeHistory(): int { return ChangeHistoryClasses::CLASS_AGREEMENT_DECLINE; } public function getChangeLoggedAttributes() { return []; } public function getOldClass(): ChangeLoggedModelInterface { return $this; } public function getEntityChangeType(): int { return ChangeHistory::CHANGE_HISTORY_AGREEMENT_DECLINE; } public function getEntityIdentifier(): ?string { if ($this->agreement->speciality !== null) { return $this->agreement->speciality->getEntityIdentifier(); } return ''; } public function getChangeHistoryHandler(): ?ChangeHistoryHandlerInterface { return null; } public function setChangeHistoryHandler(ChangeHistoryHandlerInterface $handler) { return null; } public function getIdentityString(): string { return $this->filename; } public function getPropsToCompare(): array { return ArrayHelper::merge( array_keys($this->attributes), [ 'filename', ] ); } public function getIsSentTo1C(): bool { return !empty($this->sent_at); } }