我的应用程序曾经与注册用户配合得很好,但现在不能了。
这是我的模型用户的一部分
protected $fillable = [
'prenom', 'nom', 'email','photo_path','password',
];
这是我的验证函数:
protected function validator(array $data)
{
return Validator::make($data, [
'prenom' => 'required|string|max:255',
'nom' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'photo_path' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:10000',
'password' => 'required|string|min:6|confirmed',
]);
}
这是我的创建函数:
protected function create(array $data)
{
dd($data);
$photoInput = request('photo_path');
$userPhotoPath='users';
$storagePhotoPath = Storage::disk('images')->put($userPhotoPath, $photoInput);
return User::create([
'prenom' => $data['prenom'],
'nom' => $data['nom'],
'email' => $data['email'],
'photo_path' => $storagePhotoPath,
'password' => Hash::make($data['password']),
]);
}
- POST 请求工作(返回 302(,但返回输入值 - 身份验证路由在 Web 中声明.php - 验证工作良好
但是 PHP 解释器没有进入创建函数...
我只是在调试栏中看到该信息:
The given data was invalid./home/e7250/Laravel/ManageMyWorkLife/vendor/laravel/framework/src/Illuminate/Validation/Validator.php#306IlluminateValidationValidationException
public function validate()
{
if ($this->fails()) {
throw new ValidationException($this);
}
$data = collect($this->getData())
但我的验证工作正常,因为我的输入文本附近有错误消息。 所以我不明白那个错误消息...
你有什么线索吗?
好吧,你需要在运行某些东西之前删除 dd((; 函数。其他明智的做法是,它将结束所有其他操作的执行。
检查您的用户模型是否有构造函数,如果是,请将其删除并检查问题是否仍然存在。这为我修复了它。