CanFinalize.php
3 years ago
HasCharge.php
3 years ago
HasCheckout.php
3 years ago
HasCoupon.php
3 years ago
HasCustomer.php
3 years ago
HasDiscount.php
3 years ago
HasImageSizes.php
2 years ago
HasOrder.php
3 years ago
HasPaymentIntent.php
3 years ago
HasPaymentMethod.php
3 years ago
HasPrice.php
3 years ago
HasProcessorType.php
3 years ago
HasProduct.php
3 years ago
HasPurchase.php
3 years ago
HasPurchases.php
3 years ago
HasRefund.php
3 years ago
HasShippingAddress.php
3 years ago
HasSubscription.php
3 years ago
HasSubscriptions.php
3 years ago
SyncsCustomer.php
3 years ago
HasSubscriptions.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Models\Traits; |
| 4 | |
| 5 | use SureCart\Models\Subscription; |
| 6 | |
| 7 | /** |
| 8 | * If the model has an attached customer. |
| 9 | */ |
| 10 | trait HasSubscriptions { |
| 11 | /** |
| 12 | * Set the subscriptions attribute |
| 13 | * |
| 14 | * @param object $value Subscription data array. |
| 15 | * @return void |
| 16 | */ |
| 17 | public function setSubscriptionAttribute( $value ) { |
| 18 | $this->setCollection( 'subscriptions', $value, Subscription::class ); |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Does this have subscriptions? |
| 23 | * |
| 24 | * @return boolean |
| 25 | */ |
| 26 | public function hasSubscriptions() { |
| 27 | return count( $this->attributes['subscriptions'] ?? [] ) > 0; |
| 28 | } |
| 29 | } |
| 30 |