Dan
Dan

Reputation: 526

Laravel invoice error

Using Laravel 5.2, I'm generating a list of invoices which works fine with the following code:

$owner = User::where("accountId",Auth::user()
->accountId)
->where("owner",1)
->first();
$invoices = $owner->invoices();

However when I try to download the invoice

return $this->owner->downloadInvoice($id, [
    'vendor'  => 'XXXXXXX',
    'product' => 'XXXXXXX',
]);

I get the following error

FatalErrorException in 0aba430056a58a8038d61445deab8578 line 133: Call to undefined method Laravel\Cashier\InvoiceItem::startDateString()

The error seems to be coming from this block in the receipt template, but after an extensive Googling' session I can't seem to find any answers.

            <!-- Display The Subscriptions -->
            @foreach ($invoice->subscriptions() as $subscription)
                <tr>
                    <td>Subscription ({{ $subscription->quantity }})</td>
                    <td>{{ $subscription->startDateString() }} - {{ $subscription->endDateString() }}</td>
                    <td>{{ $subscription->dollars() }}</td>
                </tr>
            @endforeach

Any ideas?

Upvotes: 1

Views: 937

Answers (1)

Dan
Dan

Reputation: 526

I believe the invoice template was from an older version of Laravel. I've updated the template to this:

        @foreach ($invoice->subscriptions() as $subscription)
            <tr>
                <td>Subscription ({{ $subscription->quantity }})</td>
                <td>{{ $subscription->startDate() }} - {{ $subscription->endDate() }}</td>
                <td>{{ $subscription->total() }}</td>
            </tr>
        @endforeach

And it seems to be working

Upvotes: 3

Related Questions