Answer the question
In order to leave comments, you need to log in
How to use the validate setting multiple times for similar controllers?
The question refers to the Laravel 5.4 framework.
The following is of interest:
For example, there is such a check for the registration form:
$this->validate($request, [
'name' => 'required|min:2|max:20',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
public function scopeProfileValidate() {
$data = [
'name' => 'required|min:12|max:20',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
];
return $data;
}
$this->validate($request, User::ProfileValidate());
Answer the question
In order to leave comments, you need to log in
If you happen to read the documentation, you will come across this thing:
And no scopes and traits are needed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question