I am using laravel 5.3, I have listings table with hasOne relationship to cities table.
public function city()
{
return $this->hasOne('App\City', 'id', 'city_id');
}
on my view
this cause error
Trying to get property of non-object
But when I change the method name to other than city,
public function foo()
{
return $this->hasOne('App\City', 'id', 'city_id');
}
on my view
This one works.
What cause the problem with city method name? I have never problem with city method name in other projects.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire