2018-07-05 19:30:36 -07:00
|
|
|
<?php
|
2018-11-01 19:59:50 -07:00
|
|
|
|
2018-07-05 19:30:36 -07:00
|
|
|
namespace App\Http\Traits;
|
|
|
|
|
2018-11-01 19:59:50 -07:00
|
|
|
use App\Models\Setting;
|
|
|
|
|
2018-07-05 19:30:36 -07:00
|
|
|
trait UniqueSerialTrait
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Prepare a unique_ids rule, adding a model identifier if required.
|
|
|
|
*
|
2018-11-01 19:59:50 -07:00
|
|
|
* @param array $parameters
|
|
|
|
* @param string $field
|
|
|
|
*
|
2018-07-05 19:30:36 -07:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function prepareUniqueSerialRule($parameters, $field)
|
|
|
|
{
|
2018-11-01 19:59:50 -07:00
|
|
|
if ($settings = Setting::getSettings()) {
|
|
|
|
if ($settings->unique_serial == '1') {
|
|
|
|
return 'unique_undeleted:'.$this->table.','.$this->getKey();
|
2018-07-09 21:57:45 -07:00
|
|
|
}
|
2018-07-05 19:30:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|