Fixed #5751 - added option for unique constraint on serial

This commit is contained in:
snipe
2018-07-05 19:30:36 -07:00
parent a44bd9abe0
commit 339263a295
6 changed files with 78 additions and 3 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Traits;
trait UniqueSerialTrait
{
/**
* Prepare a unique_ids rule, adding a model identifier if required.
*
* @param array $parameters
* @param string $field
* @return string
*/
protected function prepareUniqueSerialRule($parameters, $field)
{
$settings = \App\Models\Setting::first();
if ($settings->unique_serial=='1') {
return 'unique_undeleted:'.$this->table.','. $this->getKey();
}
}
}