mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
change message for number validation
This commit is contained in:
@ -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.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user