Tasks Module Stage 3: Attachments

- Add migration for task_attachments table
- Create TaskAttachmentModel with file handling methods
- Add TaskService methods for upload/delete attachments
- Add API routes for attachments (upload, delete, download)
- Add controller methods for attachment operations
- Add UI section in task view with file upload form
- Add JavaScript handlers for AJAX file operations
This commit is contained in:
2026-02-08 19:43:39 +00:00
parent 7ebca3c762
commit a9976a5d85
6 changed files with 463 additions and 0 deletions
@@ -0,0 +1,70 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateTaskAttachmentsTable extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'task_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => false,
],
'file_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => false,
],
'file_path' => [
'type' => 'VARCHAR',
'constraint' => 500,
'null' => false,
],
'file_size' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'file_type' => [
'type' => 'VARCHAR',
'constraint' => 100,
'default' => '',
],
'uploaded_by' => [
'type' => 'INT',
'constraint' => 11,
'null' => false,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addKey('task_id');
$this->forge->addForeignKey('task_id', 'tasks', 'id', '', 'CASCADE');
$this->forge->createTable('task_attachments');
}
public function down()
{
$this->forge->dropTable('task_attachments');
}
}