【发布时间】:2020-02-18 04:07:39
【问题描述】:
我的应用程序过去可以很好地与注册用户配合使用,但现在不行了。
这里是我的模型用户的一部分
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)但返回输入值 - Auth Route 在 web.php 中声明 - 验证运行良好
但是 php 解释器没有进入 create 函数...
我只是在调试栏中看到该信息:
The given data was invalid./home/e7250/Laravel/ManageMyWorkLife/vendor/laravel/framework/src/Illuminate/Validation/Validator.php#306Illuminate\Validation\ValidationException
public function validate()
{
if ($this->fails()) {
throw new ValidationException($this);
}
$data = collect($this->getData())
但我的验证工作正常,因为我的 InputTexte 附近有错误消息。 所以我不明白那个错误信息......
你有什么线索吗?
【问题讨论】: