Implement project board status workflow
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketWorklogEntry;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<TicketWorklogEntry>
|
||||
*/
|
||||
class TicketWorklogEntryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'actor_id' => User::factory(),
|
||||
'changes' => [
|
||||
'from' => 'Backlog',
|
||||
'to' => 'In Progress',
|
||||
],
|
||||
'entry_type' => 'status_changed',
|
||||
'summary' => 'Moved from Backlog to In Progress.',
|
||||
'ticket_id' => Ticket::factory(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
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::create('ticket_worklog_entries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('ticket_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('actor_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('entry_type');
|
||||
$table->text('summary');
|
||||
$table->json('changes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ticket_worklog_entries');
|
||||
}
|
||||
};
|
||||
@@ -18,6 +18,7 @@ class DatabaseSeeder extends Seeder
|
||||
BoardColumnSeeder::class,
|
||||
ProjectTicketMetadataSeeder::class,
|
||||
TicketSeeder::class,
|
||||
TicketWorklogEntrySeeder::class,
|
||||
TeamSeeder::class,
|
||||
ProjectAccessSeeder::class,
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketWorklogEntry;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TicketWorklogEntrySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$defaultActor = User::query()->orderBy('id')->first();
|
||||
|
||||
Ticket::query()
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->each(function (Ticket $ticket) use ($defaultActor): void {
|
||||
TicketWorklogEntry::factory()->create([
|
||||
'actor_id' => $defaultActor?->id,
|
||||
'changes' => [
|
||||
'from' => null,
|
||||
'to' => 'Backlog',
|
||||
],
|
||||
'entry_type' => 'created',
|
||||
'summary' => 'Ticket was created in Backlog.',
|
||||
'ticket_id' => $ticket->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user