我对laravel很陌生,在授权过程中遇到了一些困难。我在mysql中使用php移植:刷新重新创建了一个空用户表。当我进入注册页面,填写字段并点击注册表时,mysql中的表将不会被更新。我被重定向到我设置的正确的网页链接,所以这个部分似乎在工作。
我已经确保mysql连接到了我的laravel项目,所以连接不是问题。
下面是AuthController.php中的代码。注册和登录的视图是使用php artisan make:auth命令生成的。
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}下面是我的User.php文件中的代码,它位于app目录中。
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Users extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];}
发布于 2016-02-17 20:28:10
为了使用create,您需要在User model $fillable array中指定
protected $fillable = [
'email',
'password',
'name',
];或$protected (所以值需要更新)读取更多的文档
https://stackoverflow.com/questions/35464826
复制相似问题