You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Model::preventAccessingMissingAttributes(); and your Billable model doesn't contain name and/or email and/or phone
and you use the syncStripeCustomerDetails method
You get an exception
Illuminate\Database\Eloquent\MissingAttributeException
The attribute [phone] either does not exist or was not retrieved for model [App\Models\Vessel].
This is because Concerns/ManagesCustomer::syncStripeCustomerDetails() calls $this->stripeName(), $this->stripeEmail() and $this->stripePhone() these in turn are simple $this->name ?? null etc. the act of calling $this->name when name doesn't exist as an attribute on the model triggers the Exception.
I believe changing $this->name to $this->hasAttribute('name') ? $this->name : null; fixes the problem.
The work around is to override these methods and use the hasAttribute check, or simply return null if you do not implement those columns.
Steps To Reproduce
Enabled Model::preventAccessingMissingAttributes(); in your project
call $this->syncStripeCustomerDetails() on a Billable model
The text was updated successfully, but these errors were encountered:
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
Cashier Stripe Version
15.2
Laravel Version
11.23
PHP Version
8.2
Database Driver & Version
No response
Description
When using
Model::preventAccessingMissingAttributes();
and your Billable model doesn't containname
and/oremail
and/orphone
and you use the
syncStripeCustomerDetails
methodYou get an exception
This is because
Concerns/ManagesCustomer::syncStripeCustomerDetails()
calls$this->stripeName()
,$this->stripeEmail()
and$this->stripePhone()
these in turn are simple$this->name ?? null
etc. the act of calling$this->name
when name doesn't exist as an attribute on the model triggers the Exception.I believe changing
$this->name
to$this->hasAttribute('name') ? $this->name : null;
fixes the problem.The work around is to override these methods and use the hasAttribute check, or simply return null if you do not implement those columns.
Steps To Reproduce
Model::preventAccessingMissingAttributes();
in your project$this->syncStripeCustomerDetails()
on a Billable modelThe text was updated successfully, but these errors were encountered: