|
@@ -415,14 +415,12 @@ class Validator {
|
|
|
*/
|
|
|
protected function validate_unique($attribute, $value, $parameters)
|
|
|
{
|
|
|
- if (is_null($this->db)) $this->db = Database::connection();
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($parameters[1])) $attribute = $parameters[1];
|
|
|
|
|
|
- $query = $this->db->table($parameters[0])->where($attribute, '=', $value);
|
|
|
+ $query = $this->db()->table($parameters[0])->where($attribute, '=', $value);
|
|
|
|
|
|
|
|
|
|
|
@@ -770,6 +768,18 @@ class Validator {
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * Get the database connection for the Validator.
|
|
|
+ *
|
|
|
+ * @return Connection
|
|
|
+ */
|
|
|
+ protected function db()
|
|
|
+ {
|
|
|
+ if ( ! is_null($this->db)) return $this->db;
|
|
|
+
|
|
|
+ return $this->db = Database::connection();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* Dynamically handle calls to custom registered validators.
|
|
|
*/
|