change message for number validation

This commit is contained in:
jayvirsinh_gohil
2021-06-17 16:23:06 +05:30
parent 6ecd9728d4
commit 4ec9b2e817

View File

@ -10,6 +10,8 @@ class UniqueNumber implements Rule
public $class; public $class;
public $type;
/** /**
* Create a new rule instance. * Create a new rule instance.
* @param string $class * @param string $class
@ -38,6 +40,8 @@ class UniqueNumber implements Rule
$uniqueNumber = $value; $uniqueNumber = $value;
} }
$this->type = $attribute;
if ($this->id && $this->class::where('id', $this->id)->where($attribute, $uniqueNumber)->first()) { if ($this->id && $this->class::where('id', $this->id)->where($attribute, $uniqueNumber)->first()) {
return true; return true;
} }
@ -56,6 +60,7 @@ class UniqueNumber implements Rule
*/ */
public function message() public function message()
{ {
return 'Invalid number passed.'; $type = str_replace('_', ' ', $this->type);
return "Invalid {$type} passed.";
} }
} }