table = 'users'; $this->guarded = [ 'password', 'email', 'remember_token' ]; $this->hidden = [ 'password', 'remember_token' ]; $this->append([ 'country_name', 'country_flag' ]); } // custom attribute get{name}Attribute() public function getAvatarAttribute($path) { if ($path) { if (Str::isUrl($path)) { return $path; } else { return Storage::disk('public')->url($path); } } return asset('img/avatar.png'); } public function getCountryNameAttribute() { $countries = HCountry::getByCache(); return $countries ->where('code', $this->country_code) ->value('name'); } public function getCountryFlagAttribute() { $code = $this->country_code; return asset(HCountry::PUBLIC_PATH . "/$code.svg"); } }