I am trying to get data of country name so,
I have two model
1)users model
users:
class Users extends Model
{
protected $fillable = ['fname','lname','email','password','address','state','city'];
public function address1()
{
return $this->hasOne('App\Addresses');
}
}
2)addresses model
addresses:
class addresses extends Model
{
protected $fillable = ['user_id','country'];
public function user()
{
return $this->belongTo('App\users');
}
}
now I am getting output - it is an error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'addresses.users_id' in 'where clause' (SQL: select * from
addresses
whereaddresses
.users_id
= 5 andaddresses
.users_id
is not null andaddresses
.id
= 2 limit 1) (View: /Applications/XAMPP/xamppfiles/htdocs/demo/resources/views/profiles.blade.php)
please, solve my problem.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire