If evolution force the ticket status on estimateTodo

This commit is contained in:
Jérémy Munsch 2021-05-21 14:34:45 +02:00
parent 6ed570709b
commit fe252fa0ff

View file

@ -30,6 +30,12 @@ class Ticket extends Model
protected static function booted()
{
static::creating(function (Ticket $ticket) {
// If evolution force the ticket status on estimateTodo
if ($ticket->type->equals(TicketType::evolution())) {
$ticket->status = TicketStatus::estimateTodo();
}
});
static::updating(function (Ticket $ticket) {
$oldStatus = Ticket::where('id', $ticket->id)->first()->status;
if (!$ticket->status->equals($oldStatus)) {