looks fine to me. How are you referencing it in the view?
Address3 Mutator not working because I don't quite get it
We have US companies with city, state and zip fields and international companies using an address3 field in the database (US companies address3 is null). I wanted to simplify addresses by concatenating the 3 US fields into the address3 field for similarity.
I added this as my mutator but I still get no display in the view:
public function getAddress3Attribute()
{
if($this->address3) {
return $this->address3;
} else {
return $this->city . ', ' . $this->state . ' ' . $this->zip;
}
}
Don't forget PHP's string substitution instead of concatenation sometimes gives more readable code;
return "{$this->attributes['address']} {$this->attributes['address2']} {$this->attributes['city']}, {$this->attributes['state']} {$this->attributes['zip']}";
Also, decorating your views should not really be a function of your model - you really need a view helper function.
Google maps: https://developers.google.com/maps/documentation/embed/
Please or to participate in this conversation.