Category Archives: Laravel

Solved. Laravel Error ‘Attempt to read property “nationality” on int’

I was getting an error in Laravel when trying to access a value from a related table, after defining relationships in the relevant models. Attempt to read property “nationality” on int I had defined the relationship in my model as follows: public function nationality(){ return $this->belongsTo(Country::class, ‘nationality’, ‘countryid’); } After trying many things to fix… Read More »