Hi,
I've implemented cashier for 2 types of subscriptions. Each separate "products" in Stripe. I'm trying to generate a receipt using the downloadInvoice function.
To get the ID of the invoice, I want to be sure I query for the selected subscription.
I think I have the flow but getting stuck querying the nested Invoice attributes in the collection.
// Get subscription by product/plan name
$subscription = $model->subscription($model->plan_name);
// Get invoice based on subscription id
dd($model->invoices()->where('invoice.subscription','=',$subscription->stripe_id));
That comes out null even though if I dd on $model->invoices() I see the invoice in the collection with the subscription attribute.
Collection {#571 ▼
#items: array:1 [▼
0 => Invoice {#539 ▼
#owner: Business {#574 ▶}
#invoice: Invoice {#568 ▶}
#items: null
}
]
}
Am I complicating this or am I querying incorrectly?