table = $table; $this->md5Field = $md5Field; $this->excludeField = $excludeField; $this->excludeVal = $excludeVal; $this->nameField = $nameField; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { return DB::table($this->table)->where($this->excludeField, '!=', $this->excludeVal)->where($this->md5Field, md5($value))->doesntExist(); } /** * Get the validation error message. * * @return string */ public function message() { return ":attribute must be unique"; } }