diff --git a/src/Observers/TicketObserver.php b/src/Observers/TicketObserver.php index 8a99801..70cefbb 100644 --- a/src/Observers/TicketObserver.php +++ b/src/Observers/TicketObserver.php @@ -4,6 +4,7 @@ namespace RexlManu\LaravelTickets\Observers; +use Ramsey\Uuid\Uuid; use RexlManu\LaravelTickets\Events\TicketCloseEvent; use RexlManu\LaravelTickets\Events\TicketOpenEvent; use RexlManu\LaravelTickets\Models\Ticket; @@ -44,4 +45,11 @@ public function deleting(Ticket $ticket) $ticket->messages()->get()->each(fn(TicketMessage $ticketMessage) => $ticketMessage->delete()); } + public function creating(Ticket $ticket) + { + if (config('laravel-tickets.model.uuid') && empty($model->id)) { + $ticket->id = Uuid::uuid4(); + } + } + } diff --git a/src/Traits/HasConfigModel.php b/src/Traits/HasConfigModel.php index 92c864d..78633c0 100644 --- a/src/Traits/HasConfigModel.php +++ b/src/Traits/HasConfigModel.php @@ -4,8 +4,6 @@ namespace RexlManu\LaravelTickets\Traits; -use Ramsey\Uuid\Uuid; - trait HasConfigModel { @@ -18,14 +16,4 @@ public function isIncrementing() { return config('laravel-tickets.model.incrementing'); } - - public static function bootHasUuid() - { - static::creating(function ($model) { - if (config('laravel-tickets.model.uuid') && empty($model->id)) { - $model->id = Uuid::uuid4(); - } - }); - } - }