mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Merge branch 'number-validation' into 'master'
change message for number validation See merge request mohit.panjvani/crater-web!770
This commit is contained in:
@ -10,6 +10,8 @@ class UniqueNumber implements Rule
|
||||
|
||||
public $class;
|
||||
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
* @param string $class
|
||||
@ -38,6 +40,8 @@ class UniqueNumber implements Rule
|
||||
$uniqueNumber = $value;
|
||||
}
|
||||
|
||||
$this->type = $attribute;
|
||||
|
||||
if ($this->id && $this->class::where('id', $this->id)->where($attribute, $uniqueNumber)->first()) {
|
||||
return true;
|
||||
}
|
||||
@ -56,6 +60,7 @@ class UniqueNumber implements Rule
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return 'Invalid number passed.';
|
||||
$type = str_replace('_', ' ', $this->type);
|
||||
return "{$type} is already used.";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user