diff --git a/database/factories/FlowFactory.php b/database/factories/FlowFactory.php index 6ccb573..97d354b 100644 --- a/database/factories/FlowFactory.php +++ b/database/factories/FlowFactory.php @@ -1,9 +1,9 @@ uuid('id')->primary(); @@ -44,14 +48,8 @@ public function up(): void $table->dateTime('planned_start_at')->nullable(); $table->dateTime('end_at')->nullable()->index(); $table->dateTime('planned_end_at')->nullable(); - $table->dateTime('canceled_at')->nullable(); - $table->dateTime('closed_at')->nullable()->index(); $table->dateTime('embargo_at')->nullable(); - $table->dateTime('fixed_at')->nullable(); $table->dateTime('postponed_at')->nullable(); - $table->dateTime('published_at')->nullable(); - $table->dateTime('released_at')->nullable(); - $table->dateTime('resolved_at')->nullable(); $table->dateTime('resumed_at')->nullable(); $table->dateTime('suspended_at')->nullable(); @@ -78,48 +76,41 @@ public function up(): void $table->bigInteger('x')->nullable(); $table->bigInteger('y')->nullable(); $table->bigInteger('z')->nullable(); - $table->decimal('r', 65, 10)->nullable()->default(null); - $table->decimal('theta', 10, 6)->nullable()->default(null); - $table->decimal('rho', 10, 6)->nullable()->default(null); - $table->decimal('phi', 10, 6)->nullable()->default(null); - $table->decimal('elevation', 65, 10)->nullable()->default(null); - $table->decimal('latitude', 8, 6)->nullable()->default(null); - $table->decimal('longitude', 9, 6)->nullable()->default(null); + $table->decimal('r', 65, 10)->nullable(); + $table->decimal('theta', 10, 6)->nullable(); + $table->decimal('rho', 10, 6)->nullable(); + $table->decimal('phi', 10, 6)->nullable(); + $table->decimal('elevation', 65, 10)->nullable(); + $table->decimal('latitude', 8, 6)->nullable(); + $table->decimal('longitude', 9, 6)->nullable(); // Flags $table->boolean('active')->default(1)->index(); - $table->boolean('canceled')->default(0); - $table->boolean('closed')->default(0); - $table->boolean('completed')->default(0); - $table->boolean('duplicate')->default(0); - $table->boolean('fixed')->default(0); + $table->boolean('cron')->default(0)->index(); $table->boolean('flagged')->default(0); $table->boolean('internal')->default(0); $table->boolean('locked')->default(0); $table->boolean('pending')->default(0); $table->boolean('planned')->default(0); $table->boolean('problem')->default(0); - $table->boolean('published')->default(0); - $table->boolean('released')->default(0); $table->boolean('retired')->default(0); - $table->boolean('resolved')->default(0); $table->boolean('suspended')->default(0); $table->boolean('unknown')->default(0); - // Strings + // Columns $table->string('label')->default(''); $table->string('title')->default(''); $table->string('byline')->default(''); - $table->string('slug')->nullable()->default(null)->index(); + $table->string('slug')->nullable()->index(); $table->string('url')->default(''); $table->string('description')->default(''); $table->string('introduction')->default(''); $table->mediumText('content')->nullable(); $table->mediumText('summary')->nullable(); - // UI + // Ui $table->string('icon')->default(''); $table->string('image')->default(''); @@ -133,6 +124,10 @@ public function up(): void $table->json('meta')->nullable()->default(new Expression('(JSON_OBJECT())')); $table->json('notes')->nullable()->default(new Expression('(JSON_ARRAY())'))->comment('Array of note objects'); $table->json('options')->nullable()->default(new Expression('(JSON_OBJECT())')); + $table->json('backlog')->nullable()->default(new Expression('(JSON_OBJECT())')); + $table->json('board')->nullable()->default(new Expression('(JSON_OBJECT())')); + $table->json('roadmap')->nullable()->default(new Expression('(JSON_OBJECT())')); + $table->json('sources')->nullable()->default(new Expression('(JSON_OBJECT())')); }); } diff --git a/database/migrations/2020_01_02_100001_create_matrix_milestones_table.php b/database/migrations/2020_01_02_100001_create_matrix_milestones_table.php index f7542fa..8c18b2c 100644 --- a/database/migrations/2020_01_02_100001_create_matrix_milestones_table.php +++ b/database/migrations/2020_01_02_100001_create_matrix_milestones_table.php @@ -1,15 +1,18 @@ uuid('id')->primary(); @@ -62,8 +66,8 @@ public function up(): void $table->dateTime('postponed_at')->nullable(); $table->dateTime('published_at')->nullable(); $table->dateTime('released_at')->nullable(); - $table->dateTime('resumed_at')->nullable(); $table->dateTime('resolved_at')->nullable()->index(); + $table->dateTime('resumed_at')->nullable(); $table->dateTime('suspended_at')->nullable(); // Permissions @@ -89,13 +93,13 @@ public function up(): void $table->bigInteger('x')->nullable(); $table->bigInteger('y')->nullable(); $table->bigInteger('z')->nullable(); - $table->decimal('r', 65, 10)->nullable()->default(null); - $table->decimal('theta', 10, 6)->nullable()->default(null); - $table->decimal('rho', 10, 6)->nullable()->default(null); - $table->decimal('phi', 10, 6)->nullable()->default(null); - $table->decimal('elevation', 65, 10)->nullable()->default(null); - $table->decimal('latitude', 8, 6)->nullable()->default(null); - $table->decimal('longitude', 9, 6)->nullable()->default(null); + $table->decimal('r', 65, 10)->nullable(); + $table->decimal('theta', 10, 6)->nullable(); + $table->decimal('rho', 10, 6)->nullable(); + $table->decimal('phi', 10, 6)->nullable(); + $table->decimal('elevation', 65, 10)->nullable(); + $table->decimal('latitude', 8, 6)->nullable(); + $table->decimal('longitude', 9, 6)->nullable(); // Flags @@ -103,6 +107,7 @@ public function up(): void $table->boolean('canceled')->default(0); $table->boolean('closed')->default(0); $table->boolean('completed')->default(0); + $table->boolean('cron')->default(0)->index(); $table->boolean('duplicate')->default(0); $table->boolean('fixed')->default(0); $table->boolean('flagged')->default(0); @@ -118,19 +123,19 @@ public function up(): void $table->boolean('suspended')->default(0); $table->boolean('unknown')->default(0); - // Strings + // Columns $table->string('label')->default(''); $table->string('title')->default(''); $table->string('byline')->default(''); - $table->string('slug')->nullable()->default(null)->index(); + $table->string('slug')->nullable()->index(); $table->string('url')->default(''); $table->string('description')->default(''); $table->string('introduction')->default(''); $table->mediumText('content')->nullable(); $table->mediumText('summary')->nullable(); - // UI + // Ui $table->string('icon')->default(''); $table->string('image')->default(''); diff --git a/src/Models/Flow.php b/src/Models/Flow.php index 6010df5..f48c52f 100644 --- a/src/Models/Flow.php +++ b/src/Models/Flow.php @@ -1,9 +1,9 @@ null, 'parent_id' => null, 'flow_type' => null, + 'matrix_id' => null, 'note_id' => null, 'tag_id' => null, 'team_id' => null, @@ -37,14 +115,8 @@ class Flow extends Model 'planned_start_at' => null, 'end_at' => null, 'planned_end_at' => null, - 'canceled_at' => null, - 'closed_at' => null, 'embargo_at' => null, - 'fixed_at' => null, 'postponed_at' => null, - 'published_at' => null, - 'released_at' => null, - 'resolved_at' => null, 'resumed_at' => null, 'suspended_at' => null, 'gids' => 0, @@ -58,7 +130,7 @@ class Flow extends Model 'status' => 0, 'rank' => 0, 'size' => 0, - 'matrix' => '', + 'matrix' => '{}', 'x' => null, 'y' => null, 'z' => null, @@ -70,21 +142,14 @@ class Flow extends Model 'latitude' => null, 'longitude' => null, 'active' => true, - 'canceled' => false, - 'closed' => false, - 'completed' => false, - 'duplicate' => false, - 'fixed' => false, + 'cron' => false, 'flagged' => false, 'internal' => false, 'locked' => false, 'pending' => false, 'planned' => false, 'problem' => false, - 'published' => false, - 'released' => false, 'retired' => false, - 'resolved' => false, 'suspended' => false, 'unknown' => false, 'label' => '', @@ -101,10 +166,14 @@ class Flow extends Model 'avatar' => '', 'ui' => '{}', 'assets' => '{}', + 'backlog' => '{}', + 'board' => '{}', 'flow' => '{}', 'meta' => '{}', 'notes' => '[]', 'options' => '{}', + 'roadmap' => '{}', + 'sources' => '{}', ]; /** @@ -116,6 +185,7 @@ class Flow extends Model 'owned_by_id', 'parent_id', 'flow_type', + 'matrix_id', 'note_id', 'tag_id', 'team_id', @@ -123,15 +193,9 @@ class Flow extends Model 'planned_start_at', 'end_at', 'planned_end_at', - 'canceled_at', - 'closed_at', 'embargo_at', - 'fixed_at', 'postponed_at', - 'published_at', - 'released_at', 'resumed_at', - 'resolved_at', 'suspended_at', 'gids', 'po', @@ -156,21 +220,14 @@ class Flow extends Model 'latitude', 'longitude', 'active', - 'canceled', - 'closed', - 'completed', - 'duplicate', - 'fixed', + 'cron', 'flagged', 'internal', 'locked', 'pending', 'planned', 'problem', - 'published', - 'released', 'retired', - 'resolved', 'suspended', 'unknown', 'label', @@ -187,10 +244,13 @@ class Flow extends Model 'avatar', 'ui', 'assets', + 'backlog', + 'board', 'flow', 'meta', - 'notes', 'options', + 'roadmap', + 'sources', ]; /** @@ -209,15 +269,9 @@ protected function casts(): array 'planned_start_at' => 'datetime', 'end_at' => 'datetime', 'planned_end_at' => 'datetime', - 'canceled_at' => 'datetime', - 'closed_at' => 'datetime', 'embargo_at' => 'datetime', - 'fixed_at' => 'datetime', 'postponed_at' => 'datetime', - 'published_at' => 'datetime', - 'released_at' => 'datetime', 'resumed_at' => 'datetime', - 'resolved_at' => 'datetime', 'suspended_at' => 'datetime', 'gids' => 'integer', 'po' => 'integer', @@ -230,7 +284,7 @@ protected function casts(): array 'status' => 'integer', 'rank' => 'integer', 'size' => 'integer', - 'matrix' => 'string', + 'matrix' => 'array', 'x' => 'integer', 'y' => 'integer', 'z' => 'integer', @@ -242,21 +296,14 @@ protected function casts(): array 'latitude' => 'float', 'longitude' => 'float', 'active' => 'boolean', - 'canceled' => 'boolean', - 'closed' => 'boolean', - 'completed' => 'boolean', - 'duplicate' => 'boolean', - 'fixed' => 'boolean', + 'cron' => 'boolean', 'flagged' => 'boolean', 'internal' => 'boolean', 'locked' => 'boolean', 'pending' => 'boolean', 'planned' => 'boolean', 'problem' => 'boolean', - 'published' => 'boolean', - 'released' => 'boolean', 'retired' => 'boolean', - 'resolved' => 'boolean', 'suspended' => 'boolean', 'unknown' => 'boolean', 'label' => 'string', @@ -273,6 +320,8 @@ protected function casts(): array 'avatar' => 'string', 'ui' => 'array', 'assets' => 'array', + 'backlog' => 'array', + 'board' => 'array', 'flow' => 'array', 'meta' => 'array', 'notes' => 'array', @@ -282,6 +331,18 @@ protected function casts(): array ]; } + /** + * The matrix of the flow. + */ + public function matrix(): HasOne + { + return $this->hasOne( + Matrix::class, + 'id', + 'matrix_id' + ); + } + /** * The note of the flow. */ diff --git a/src/Models/Milestone.php b/src/Models/Milestone.php index eacebe5..38e6f07 100644 --- a/src/Models/Milestone.php +++ b/src/Models/Milestone.php @@ -1,9 +1,9 @@ null, 'epic_id' => null, 'flow_id' => null, + 'matrix_id' => null, 'note_id' => null, 'project_id' => null, 'release_id' => null, @@ -51,11 +154,9 @@ class Milestone extends Model 'canceled_at' => null, 'closed_at' => null, 'embargo_at' => null, - 'fixed_at' => null, 'postponed_at' => null, 'published_at' => null, 'released_at' => null, - 'resolved_at' => null, 'resumed_at' => null, 'suspended_at' => null, 'gids' => 0, @@ -69,7 +170,7 @@ class Milestone extends Model 'status' => 0, 'rank' => 0, 'size' => 0, - 'matrix' => '', + 'matrix' => '{}', 'x' => null, 'y' => null, 'z' => null, @@ -84,6 +185,7 @@ class Milestone extends Model 'canceled' => false, 'closed' => false, 'completed' => false, + 'cron' => false, 'duplicate' => false, 'fixed' => false, 'flagged' => false, @@ -135,6 +237,7 @@ class Milestone extends Model 'board_id', 'epic_id', 'flow_id', + 'matrix_id', 'note_id', 'project_id', 'release_id', @@ -152,12 +255,10 @@ class Milestone extends Model 'canceled_at', 'closed_at', 'embargo_at', - 'fixed_at', 'postponed_at', 'published_at', 'released_at', 'resumed_at', - 'resolved_at', 'suspended_at', 'gids', 'po', @@ -185,6 +286,7 @@ class Milestone extends Model 'canceled', 'closed', 'completed', + 'cron', 'duplicate', 'fixed', 'flagged', @@ -217,7 +319,6 @@ class Milestone extends Model 'board', 'flow', 'meta', - 'notes', 'options', 'roadmap', 'sources', @@ -242,12 +343,10 @@ protected function casts(): array 'canceled_at' => 'datetime', 'closed_at' => 'datetime', 'embargo_at' => 'datetime', - 'fixed_at' => 'datetime', 'postponed_at' => 'datetime', 'published_at' => 'datetime', 'released_at' => 'datetime', 'resumed_at' => 'datetime', - 'resolved_at' => 'datetime', 'suspended_at' => 'datetime', 'gids' => 'integer', 'po' => 'integer', @@ -260,7 +359,7 @@ protected function casts(): array 'status' => 'integer', 'rank' => 'integer', 'size' => 'integer', - 'matrix' => 'string', + 'matrix' => 'array', 'x' => 'integer', 'y' => 'integer', 'z' => 'integer', @@ -275,6 +374,7 @@ protected function casts(): array 'canceled' => 'boolean', 'closed' => 'boolean', 'completed' => 'boolean', + 'cron' => 'boolean', 'duplicate' => 'boolean', 'fixed' => 'boolean', 'flagged' => 'boolean', @@ -362,6 +462,18 @@ public function flow(): HasOne ); } + /** + * The matrix of the milestone. + */ + public function matrix(): HasOne + { + return $this->hasOne( + Matrix::class, + 'id', + 'matrix_id' + ); + } + /** * The project of the milestone. */ diff --git a/tests/Feature/Models/Flow/ModelTest.php b/tests/Feature/Models/Flow/ModelTest.php index f1ef2d3..cb56278 100644 --- a/tests/Feature/Models/Flow/ModelTest.php +++ b/tests/Feature/Models/Flow/ModelTest.php @@ -38,6 +38,11 @@ class ModelTest extends ModelCase 'rule' => 'create', 'modelClass' => \Playground\Matrix\Models\Flow::class, ], + 'matrix' => [ + 'key' => 'matrix_id', + 'rule' => 'create', + 'modelClass' => \Playground\Matrix\Models\Matrix::class, + ], 'note' => [ 'key' => 'note_id', 'rule' => 'create', diff --git a/tests/Feature/Models/Milestone/ModelTest.php b/tests/Feature/Models/Milestone/ModelTest.php index c21d53c..65c9637 100644 --- a/tests/Feature/Models/Milestone/ModelTest.php +++ b/tests/Feature/Models/Milestone/ModelTest.php @@ -58,6 +58,11 @@ class ModelTest extends ModelCase 'rule' => 'create', 'modelClass' => \Playground\Matrix\Models\Flow::class, ], + 'matrix' => [ + 'key' => 'matrix_id', + 'rule' => 'create', + 'modelClass' => \Playground\Matrix\Models\Matrix::class, + ], 'project' => [ 'key' => 'project_id', 'rule' => 'create', diff --git a/tests/Unit/Models/Backlog/ModelTest.php b/tests/Unit/Models/Backlog/ModelTest.php index 2b8ce28..dc7f0b5 100644 --- a/tests/Unit/Models/Backlog/ModelTest.php +++ b/tests/Unit/Models/Backlog/ModelTest.php @@ -17,6 +17,11 @@ class ModelTest extends ModelCase protected bool $hasRelationships = true; + protected array $hasMany = [ + 'sprints', + 'tickets', + ]; + protected array $hasOne = [ 'creator', 'modifier', diff --git a/tests/Unit/Models/Flow/ModelTest.php b/tests/Unit/Models/Flow/ModelTest.php index d6bdae8..1645a63 100644 --- a/tests/Unit/Models/Flow/ModelTest.php +++ b/tests/Unit/Models/Flow/ModelTest.php @@ -22,6 +22,7 @@ class ModelTest extends ModelCase 'modifier', 'owner', 'parent', + 'matrix', 'note', 'tag', 'team', diff --git a/tests/Unit/Models/Milestone/ModelTest.php b/tests/Unit/Models/Milestone/ModelTest.php index d13a36a..8b608e5 100644 --- a/tests/Unit/Models/Milestone/ModelTest.php +++ b/tests/Unit/Models/Milestone/ModelTest.php @@ -26,6 +26,7 @@ class ModelTest extends ModelCase 'board', 'epic', 'flow', + 'matrix', 'project', 'release', 'roadmap', diff --git a/tests/Unit/Models/Ticket/ModelTest.php b/tests/Unit/Models/Ticket/ModelTest.php index 5cf0dfc..72e033d 100644 --- a/tests/Unit/Models/Ticket/ModelTest.php +++ b/tests/Unit/Models/Ticket/ModelTest.php @@ -26,6 +26,7 @@ class ModelTest extends ModelCase 'board', 'completedBy', 'epic', + 'fixedBy', 'flow', 'matrix', 'milestone',