added status restriction
This commit is contained in:
@@ -22,22 +22,6 @@ class TicketStatus extends Model
|
||||
static::saving(function (self $ticketStatus): void {
|
||||
$ticketStatus->slug = Str::slug($ticketStatus->name);
|
||||
});
|
||||
|
||||
static::created(function (self $ticketStatus): void {
|
||||
$statusIds = self::query()
|
||||
->where('project_id', $ticketStatus->project_id)
|
||||
->pluck('id');
|
||||
|
||||
$ticketStatus->allowedTargetStatuses()->syncWithoutDetaching($statusIds);
|
||||
|
||||
self::query()
|
||||
->where('project_id', $ticketStatus->project_id)
|
||||
->whereKeyNot($ticketStatus->id)
|
||||
->get()
|
||||
->each(fn (self $existingStatus): array => $existingStatus
|
||||
->allowedTargetStatuses()
|
||||
->syncWithoutDetaching([$ticketStatus->id]));
|
||||
});
|
||||
}
|
||||
|
||||
public function allowedSourceStatuses(): BelongsToMany
|
||||
|
||||
Reference in New Issue
Block a user