Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Commit

Permalink
feat: 🎸 Support laravel/framework#47973
Browse files Browse the repository at this point in the history
  • Loading branch information
mpyw committed Aug 23, 2023
1 parent e3dcd0f commit 516e6cc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/UniqueViolationDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Mpyw\LaravelUniqueViolationDetector;

use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\UniqueConstraintViolationException;
use Mpyw\UniqueViolationDetector\UniqueViolationDetector as DetectorInterface;
use PDOException;

Expand All @@ -27,6 +28,10 @@ public function __construct(ConnectionInterface $connection)

public function violated(PDOException $e): bool
{
if ($e instanceof UniqueConstraintViolationException) {
return true;
}

return (
$this->detector
?: ($this->detector = (new DetectorDiscoverer())->discover($this->connection))
Expand Down

0 comments on commit 516e6cc

Please sign in to comment.