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:
@@ -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('Вложение не найдено');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user