Merge branch 'develop' into trunk
This commit is contained in:
commit
f99dac8aab
1 changed files with 13 additions and 4 deletions
|
|
@ -63,8 +63,8 @@ class Ticket extends Model
|
|||
protected static function booted()
|
||||
{
|
||||
static::creating(function (Ticket $ticket) {
|
||||
// If bug force the ticket status on new. All the others are estimateTodo.
|
||||
self::setOrder($ticket);
|
||||
// If bug force the ticket status on new. All the others are estimateTodo.
|
||||
if ($ticket->type->equals(TicketTypeEnum::bug)) {
|
||||
$ticket->status = TicketStatusEnum::new;
|
||||
} else {
|
||||
|
|
@ -108,9 +108,18 @@ class Ticket extends Model
|
|||
*/
|
||||
private static function setOrder(self $model, bool $isArchived = false): void
|
||||
{
|
||||
$model->order = \intval(
|
||||
self::query()->where('status', $isArchived ? '=' : '!=', TicketStatusEnum::archived)->max('order')
|
||||
) + 1;
|
||||
$maxOrder = \intval(self::query()->where('status', '!=', TicketStatusEnum::archived)->max('order'));
|
||||
if ($isArchived) {
|
||||
$request = Ticket::query()
|
||||
->where('site_id', $model->site_id)
|
||||
->whereNot('status', TicketStatusEnum::archived)
|
||||
->whereNot('id', $model->id)
|
||||
->whereBetween('order', [$model->order, $maxOrder]);
|
||||
$request->decrement('order', 1);
|
||||
$model->order = 0;
|
||||
return;
|
||||
}
|
||||
$model->order = $maxOrder + 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue