diff --git a/src/Id/Billable.php b/src/Id/Billable.php index 81b4737..511d9e9 100644 --- a/src/Id/Billable.php +++ b/src/Id/Billable.php @@ -29,6 +29,21 @@ trait Billable use ManagesTransactions; use ManagesUserSshKeys; + /* + * API results cached per instance. Declared, so Eloquent models don't take them for + * attributes (an undeclared property goes through Model::__set and save() then fails + * with "no such column"). + */ + protected mixed $addressesCache = null; + protected mixed $countriesCache = null; + protected mixed $defaultPaymentMethodCache = null; + protected mixed $invoicesCache = null; + protected mixed $ordersCache = null; + protected mixed $paymentMethodsCache = null; + protected mixed $subscriptionsCache = null; + protected mixed $transactionsCache = null; + protected mixed $userDataCache = null; + /** * Get the currently authenticated user. * diff --git a/tests/Id/BillableModelTest.php b/tests/Id/BillableModelTest.php new file mode 100644 index 0000000..c7d8c3a --- /dev/null +++ b/tests/Id/BillableModelTest.php @@ -0,0 +1,31 @@ +{$name.'Cache'} = 'cached'; + } + } + }; + $user->email = 'ada@example.com'; + + $user->cacheAll(); + + // save() would otherwise write them as columns ("no such column: ordersCache") + $this->assertSame(['email' => 'ada@example.com'], $user->getAttributes()); + } +}