Writing dynamic validation rules when saving a model
0
public function beforeSave()
{
$rules = [
'amount_picked' => 'numeric|min:0|max:' . $this->amount_required
];
\Validator::make($this->toArray(), $rules)->validate();
}
public function beforeValidate()
{
$this->rules['amount_picked'] = 'numeric|min:0|max:' . $this->amount_required;
}
There are no comments yet
Be the first one to comment