我正在尝试获取国名的数据,所以,
我有两个模型
1)用户模型
用户:
class Users extends Model
{
protected $fillable = ['fname','lname','email','password','address','state','city'];
public function address1()
{
return $this->hasOne('App\Addresses');
}
}
2)地址模型
地址:
class addresses extends Model
{
protected $fillable = ['user_id','country'];
public function user()
{
return $this->belongTo('App\users');
}
}
现在我得到输出 - 这是一个错误:
SQLSTATE [42S22]:未找到列:1054 'where 子句'中的未知列'addresses.users_id'(SQL:select * from
addresses
whereaddresses
.users_id
= 5 andaddresses
.users_id
is not null andaddresses
.id
= 2 limit 1)(查看:/Applications/ XAMPP/xamppfiles/htdocs/demo/resources/views/profiles.blade.php)
请解决我的问题。