From 5c0802a29c46baca414a17cb262a358039a8b04e Mon Sep 17 00:00:00 2001 From: David TANG Date: Fri, 14 Jun 2024 11:53:02 +0200 Subject: [PATCH] fix: prevent duplicate ticket_id received from expo --- src/Storage/ExpoTicketStorageMysql.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Storage/ExpoTicketStorageMysql.php b/src/Storage/ExpoTicketStorageMysql.php index a019a24..50f0331 100644 --- a/src/Storage/ExpoTicketStorageMysql.php +++ b/src/Storage/ExpoTicketStorageMysql.php @@ -22,7 +22,9 @@ public function retrieve(int $amount = 1000): Collection public function store(string $ticketId, string $token): ExpoTicketDto { - $expoTicket = ExpoTicket::create([ + $expoTicket = ExpoTicket::firstOrCreate([ + 'ticket_id' => $ticketId, + ], [ 'ticket_id' => $ticketId, 'token' => $token, ]);