Model ticket link counterparts explicitly
This commit is contained in:
@@ -60,15 +60,13 @@ class TicketLinkFactory extends Factory
|
||||
->first()
|
||||
?? TicketLinkType::factory()->for($sourceTicket->project)->create([
|
||||
'label' => 'Relates to',
|
||||
'counterpart_label' => 'Relates to',
|
||||
'position' => 1,
|
||||
])
|
||||
: TicketLinkType::query()->findOrFail($ticketLink->ticket_link_type_id);
|
||||
|
||||
$sortedIds = [$sourceTicket->id, $targetTicket->id];
|
||||
sort($sortedIds);
|
||||
|
||||
$ticketLink->source_ticket_id = $sortedIds[0];
|
||||
$ticketLink->target_ticket_id = $sortedIds[1];
|
||||
$ticketLink->source_ticket_id = $sourceTicket->id;
|
||||
$ticketLink->target_ticket_id = $targetTicket->id;
|
||||
$ticketLink->ticket_link_type_id = $ticketLinkType->id;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ class TicketLinkTypeFactory extends Factory
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$label = fake()->unique()->words(2, true);
|
||||
|
||||
return [
|
||||
'label' => fake()->unique()->words(2, true),
|
||||
'label' => $label,
|
||||
'counterpart_label' => $label,
|
||||
'position' => 1,
|
||||
'project_id' => Project::factory(),
|
||||
];
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?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::table('ticket_link_types', function (Blueprint $table) {
|
||||
$table->string('counterpart_label')->nullable()->after('label');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ticket_link_types', function (Blueprint $table) {
|
||||
$table->dropColumn('counterpart_label');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -20,8 +20,8 @@ class TicketLinkTypeSeeder extends Seeder
|
||||
TicketLinkType::factory()
|
||||
->count(2)
|
||||
->sequence(
|
||||
['label' => 'Relates to', 'position' => 1],
|
||||
['label' => 'Blocks', 'position' => 2],
|
||||
['label' => 'Relates to', 'counterpart_label' => 'Relates to', 'position' => 1],
|
||||
['label' => 'Blocks', 'counterpart_label' => 'Blocked by', 'position' => 2],
|
||||
)
|
||||
->for($project)
|
||||
->create();
|
||||
|
||||
Reference in New Issue
Block a user