spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

replaceModelAttributes when extra_attribute is missing generates an error #238

Closed electronick86 closed 3 years ago

electronick86 commented 3 years ago

Hello guys!

Am I the only one having this small issue. I use the Subscriber Replacer with extra_attributes. This generates an Array to string conversion when the extra attributes is missing.

I don't find the place in the replaceModelAttributes trait where I could correct that.

// Subscriber 1 don't have any postcode
>>> App\Subscriber::find(1)->extra_attributes->get("postcode")
=> null
>>> replaceModelAttributes("Postcode is ::subscriber.extra_attributes.postcode::", "subscriber", App\Subscriber::find(1) );
PHP Notice:  Array to string conversion in Psy Shell code on line 12
=> "Postcode is Array"

// Subscriber 2 has a postcode
>>> App\Subscriber::find(2)->extra_attributes->get("postcode")
=> 1000
>>> replaceModelAttributes("Postcode is ::subscriber.extra_attributes.postcode::", "subscriber", App\Subscriber::find(2) );
=> "Postcode is 1000"
>>> 

Any advice? Thanks a lot!

rubenvanassche commented 3 years ago

Hi @electronick86,

This should be fixed in laravel-mailcoach 2.23.7. Thanks for using Mailcoach!