hybridword

1820 经验值

我现在有3张表,一张文章(已经在使用),一张是标签,另外一张是关联表,现在想在关联表里面做2个外键,分别对应其他2张表的id,但是对于文章表的时候却提示上面的错误,这是什么原因呢?已有数据不可以做外键?

这个太简单了吧,$this->users = $users;你可以解释这个给我么?

public function __construct(UserRepository $users)
    {
        $this->users = $users;
}
群主可以解释一下这个构造方法么,还有中间那个users是怎么回事

问个问题,在设计migration文件的时候,里面那些字段的属性去哪里看?例如unsign(),index()这些

好,我今晚回去试试,你有这个文档看看不


namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

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

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

哈哈,你和我想法一样的,我试了!不行!

这是注册的

    {
        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'avatar' => '/images/avatar/default.png',
            'confirmation_token' => str_random(40),
            'password' => bcrypt($data['password']),
        ]);
        $this->sendVerifyEmailTo($user);
        return $user;
    }
     private function sendVerifyEmailTo($user)
     {
         $data = ['url' => route('email.verify',['token'=> $user ->confirmation_token]),
                   'name' => $user->name
         ];
         $template = new SendCloudTemplate('register', $data);

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

             $message->to($user->email);
         });
     }```

这是激活的,顺便提一下,他是激活成功的了
{
 $user = User::where('confirmation_token',$token)->first();

    if (is_null($user)){
        return redirect('/');
    }

    $user->is_active = 1 ;
    $user->confirmation_token =str_random(40);
    $user->save();
    Auth::login();
    return redirect('/home');
}```

我是在激活邮箱那里发生这个错误的