Answer the question
In order to leave comments, you need to log in
What's wrong with Laravel validation?
There is a controller:
<?php
namespace App\Http\Controllers\CAuth;
use App\Http\Classes\UserRegister;
use Illuminate\Http\Request;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
class CustomAuthController {
public function validate (Request $request) {
$rules = [
'username' => 'required|string|max:255',
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6',
'invite' => 'required|integer|min:6',
];
$this->validate($request, $rules);
}
}
Answer the question
In order to leave comments, you need to log in
Is this in production? logs are silent? if dev then turn on error display.
so anything can be, what kind of middleware do not let through.. offhand maybe in csrf fields?
What were you expecting when you called the validate method?
Pay attention, your controller method is also called the validation method in the controller, which, by the way, you also call from your method
Replace
with another name, it should be either store or update
Oh yeah, and you don’t inherit your controller from the base one, in this is also a problem
Must be
class CustomAuthController {
public function validate (Request $request) {
$rules = [
'username' => 'required|string|max:255',
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6',
'invite' => 'required|integer|min:6',
];
// Внимание
$request->validate($rules);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question