Can you show how you are trying to retrieve user city?
You can try namespacing City on the user model too - just so Laravel knows where to find it.
Yes, of course. This is my reflection code:
$rc = new \ReflectionClass($model);
if ($rc->hasMethod($fieldName)) {
// This two calls below are returning: "Relationship method must return
// an object of type Illuminate\Database\Eloquent\Relations\Relation"
$relation = $rc->getMethod('getAttribute')->invoke($model, $fieldName);
$rc->getMethod($fieldName)->invoke($model);
// And this one is returning: "Property city does not exist"
$rp = $rc->getProperty($fieldName);
}
The namespace is not the problem, because without reflection I can access the relationship without any problem. Thanks for your answer!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.