Add ability to set task to done, fixes ST-244

This commit is contained in:
Constantin Graf
2024-06-24 14:25:26 +02:00
committed by Gregor Vostrak
parent 75e739f6fb
commit 364168debd
9 changed files with 236 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ class TaskFactory extends Factory
'name' => $this->faker->word(),
'project_id' => Project::factory(),
'organization_id' => Organization::factory(),
'done_at' => null,
];
}
@@ -37,6 +38,15 @@ class TaskFactory extends Factory
});
}
public function isDone(): self
{
return $this->state(function (array $attributes) {
return [
'done_at' => $this->faker->dateTime('now', 'UTC'),
];
});
}
public function forOrganization(Organization $organization): self
{
return $this->state(function (array $attributes) use ($organization) {

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('tasks', function (Blueprint $table): void {
$table->dateTime('done_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('tasks', function (Blueprint $table): void {
$table->dropColumn('done_at');
});
}
};