Tasks Module Stage 2: Subtasks

- Create task_subtasks table migration
- Create TaskSubtaskModel with CRUD operations
- Add subtask API methods: addSubtask, toggleSubtask, deleteSubtask
- Update TaskService to include subtasks in getTask()
- Add Routes for subtasks API
- Update show.twig with subtasks UI and JavaScript
This commit is contained in:
2026-02-08 14:55:45 +00:00
parent d7fec7169f
commit cee6c636ad
6 changed files with 417 additions and 0 deletions
@@ -0,0 +1,54 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateTaskSubtasksTable 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,
],
'title' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'is_completed' => [
'type' => 'BOOLEAN',
'default' => false,
],
'order_index' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addForeignKey('task_id', 'tasks', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('task_subtasks');
}
public function down()
{
$this->forge->dropTable('task_subtasks');
}
}