跳到主要内容

Model

public function authenticators()
{
return $this->hasMany(Authenticator::class, 'user_id');
}

public function user()
{
return $this->belongsTo(User::class, 'user_id');
}

多ID

public function roles()
{
return $this->belongsToMany(Role::class, 'role_users', 'user_id', 'role_id');
}

拿数据

return $this->hasOne(Photos::class, 'product_id')
Products::with(photo)->get()