diff --git a/app/Http/Traits/UniqueSerialTrait.php b/app/Http/Traits/UniqueSerialTrait.php index fc2291c7a3..be9a885c08 100644 --- a/app/Http/Traits/UniqueSerialTrait.php +++ b/app/Http/Traits/UniqueSerialTrait.php @@ -13,11 +13,10 @@ trait UniqueSerialTrait */ protected function prepareUniqueSerialRule($parameters, $field) { - $settings = \App\Models\Setting::first(); - - if ($settings->unique_serial=='1') { - return 'unique_undeleted:'.$this->table.','. $this->getKey(); + if ($settings = \App\Models\Setting::first()) { + if ($settings->unique_serial=='1') { + return 'unique_undeleted:'.$this->table.','. $this->getKey(); + } } - } }