schema = $schema; $this->table = $table; $this->column = $column; $this->ignoreId = $ignoreId; } public function passes($attribute, $value) { $query = DB::table($this->schema . '.' . $this->table) ->where($this->column, $value); if ($this->ignoreId !== null) { $query->where('id', '!=', $this->ignoreId); } return !$query->exists(); } public function message() { return 'The :attribute has already been taken.'; } public function validate(string $attribute, mixed $value, Closure $fail): void { if (!$this->passes($attribute, $value)) { $fail($this->message()); } } }