Refactor: Create shared AttachmentService and AttachmentModel

- Created common AttachmentService for all modules (app/Services/)
- Created common AttachmentModel (app/Models/)
- Created common migration (app/Database/Migrations/)
- Updated Tasks module to use shared AttachmentService
- Added Twig functions: format_filesize(), get_file_icon()
- Removed duplicate TaskAttachmentModel and task_attachments migration
- AttachmentService can be used by any module: task, deal, contact, etc.
This commit is contained in:
2026-02-08 20:34:11 +00:00
parent 9c4aacefbe
commit 052560c9b4
7 changed files with 226 additions and 74 deletions
@@ -706,10 +706,10 @@ class TasksController extends BaseController
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound('Задача не найдена');
}
$attachmentModel = new \App\Modules\Tasks\Models\TaskAttachmentModel();
$attachment = $attachmentModel->find($attachmentId);
$attachmentModel = new \App\Models\AttachmentModel();
$attachment = $attachmentModel->getById($attachmentId);
if (!$attachment || $attachment['task_id'] != $taskId) {
if (!$attachment || $attachment['entity_type'] !== 'task' || $attachment['entity_id'] != $taskId) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound('Вложение не найдено');
}