![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/rentpix.corals.io/vendor/laravel/framework/src/Illuminate/Validation/Rules/ |
<?php namespace Illuminate\Validation\Rules; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Traits\Conditionable; class Unique { use Conditionable, DatabaseRule; /** * The ID that should be ignored. * * @var mixed */ protected $ignore; /** * The name of the ID column. * * @var string */ protected $idColumn = 'id'; /** * Ignore the given ID during the unique check. * * @param mixed $id * @param string|null $idColumn * @return $this */ public function ignore($id, $idColumn = null) { if ($id instanceof Model) { return $this->ignoreModel($id, $idColumn); } $this->ignore = $id; $this->idColumn = $idColumn ?? 'id'; return $this; } /** * Ignore the given model during the unique check. * * @param \Illuminate\Database\Eloquent\Model $model * @param string|null $idColumn * @return $this */ public function ignoreModel($model, $idColumn = null) { $this->idColumn = $idColumn ?? $model->getKeyName(); $this->ignore = $model->{$this->idColumn}; return $this; } /** * Convert the rule to a validation string. * * @return string */ public function __toString() { return rtrim(sprintf('unique:%s,%s,%s,%s,%s', $this->table, $this->column, $this->ignore ? '"'.addslashes($this->ignore).'"' : 'NULL', $this->idColumn, $this->formatWheres() ), ','); } }