欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

users table 用户表格 增加字段 (比如 tel 字段 )然后注册的时候 就有这个字段 生成密码 重置密码 有大用

1)注册表单中 要有这个字段 tel

2) user 模型 $fillable 要有这个字段

class User extends Model implements AuthenticatableContract, CanResetPasswordContract

{
     ...
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['name', 'email', 'password', 'tel'];
    ...
}

3) 在 
 App\Services\Registrar (\app\Services\Registrar.php) 的 
create 方法 修改为 

 public function create(array $data)
{
   return User::create([
      'name' => $data['name'],
      'email' => $data['email'],
      'password' => bcrypt($data['password']),
      'tel'=> $data['tel'],
   ]);
}

当然App\Services\Registrar (\app\Services\Registrar.php) 验证方法也要作一定的修改 

public function validator(array $data)
{
   return Validator::make($data, [
      'name' => 'required|max:255',
      'email' => 'required|email|max:255|unique:users',
      'password' => 'required|confirmed|min:6',
      'tel'=>'required|size:11|unique:users|mobile'
   ]);
}



普通分类: