I have a table that has country_code
and country_name
.
Each user in my database has country_code on their account. What I want to do is automatically return the country_name instead of the country_code for that user.
I have setup an accessor in my User model, but it doesn't seem to work.
public function getCountryCodeAttribute($value): string
{
return Country::firstWhere('country_code', $value)->get('country_name');
}
It keeps still returning the country_code
Any help would be great
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire