Implement ticket links and blocker state
This commit is contained in:
@@ -41,6 +41,12 @@ class Project extends Model
|
||||
->orderBy('position');
|
||||
}
|
||||
|
||||
public function ticketLinkTypes(): HasMany
|
||||
{
|
||||
return $this->hasMany(TicketLinkType::class)
|
||||
->orderBy('position');
|
||||
}
|
||||
|
||||
public function ticketTypes(): HasMany
|
||||
{
|
||||
return $this->hasMany(TicketType::class)
|
||||
|
||||
@@ -12,7 +12,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
#[Fillable([
|
||||
'acceptance_criteria',
|
||||
'board_column_id',
|
||||
'blocked_comment',
|
||||
'description',
|
||||
'is_blocked',
|
||||
'parent_ticket_id',
|
||||
'project_id',
|
||||
'sequence_number',
|
||||
@@ -26,6 +28,16 @@ class Ticket extends Model
|
||||
/** @use HasFactory<TicketFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_blocked' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function boardColumn(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BoardColumn::class);
|
||||
@@ -48,6 +60,18 @@ class Ticket extends Model
|
||||
return $this->belongsTo(Ticket::class, 'parent_ticket_id');
|
||||
}
|
||||
|
||||
public function ticketLinksAsSource(): HasMany
|
||||
{
|
||||
return $this->hasMany(TicketLink::class, 'source_ticket_id')
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
public function ticketLinksAsTarget(): HasMany
|
||||
{
|
||||
return $this->hasMany(TicketLink::class, 'target_ticket_id')
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\TicketLinkFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable(['source_ticket_id', 'target_ticket_id', 'ticket_link_type_id'])]
|
||||
class TicketLink extends Model
|
||||
{
|
||||
/** @use HasFactory<TicketLinkFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public function sourceTicket(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ticket::class, 'source_ticket_id');
|
||||
}
|
||||
|
||||
public function targetTicket(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ticket::class, 'target_ticket_id');
|
||||
}
|
||||
|
||||
public function ticketLinkType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TicketLinkType::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\TicketLinkTypeFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable(['label', 'position', 'project_id'])]
|
||||
class TicketLinkType extends Model
|
||||
{
|
||||
/** @use HasFactory<TicketLinkTypeFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
|
||||
public function ticketLinks(): HasMany
|
||||
{
|
||||
return $this->hasMany(TicketLink::class)
|
||||
->orderBy('id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user