lilin1986

332 经验值

代码:
protected function create(array $data)

{
    $user =  User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'avatar' => '/images/avatars/default.png',
        'confirmation_token' => str_random(40),
        'password' => bcrypt($data['password']),
    ]);

    $this->sendVerifyEmailTo($user);

    return $user;
}

protected function sendVerifyEmailTo($user)
{

   $data = [
       'name' => $user->name,
   ];
   $template = new SendCloudTemplate('test_template_active', $data);

   Mail::raw($template, function ($message) use($user) {
       $message->from('[email protected]', 'Laravel');
       $message->to($user->email);
   });

}
报错信息:
Illuminate \ Database \ QueryException (HY000)
SQLSTATE[HY000]: General error: 1364 Field 'avatar' doesn't have a default value (SQL: insert into users (name, email, password, updated_at, created_at) values (李林, entirlyelite@163.com, $2y$10$uUKooScZY.6oOfcEeWju7OX3sVNbpd2/EeFjsdkQnGrJU1fSDUuN., 2018-01-07 03:49:37, 2018-01-07 03:49:37))

报错提示 avatar 不存在默认值 , 我明明在代码里面写有值,我的做法, 我首先怀疑是不是斜线或者点 系统不认,这种符号数据库写不进去,我把值改成随便的两个字母 ,结果是一样的 ,然后我把头像字段改成允许空,然没有卵用, 麻烦老师,帮看看 ,谢谢你 祝您 新的一年里天天都有好心情