I am using Laravel 5.8 with Laravel Cashier. When I try to show a list of invoices of a user, I used this code:

@foreach (Auth::user()->invoices() as $invoice)
        <td>{{ $invoice->date()->toFormattedDateString() }}</td>
        <td>{{ $invoice->total() }}</td>
            <a href="/user/invoice/{{ $invoice->id }}">Download</a>

However, the line $invoice->date()->toFormattedDateString() gives an error:

DateTime::__construct(): Failed to parse time string (@) at position 0 (@): Unexpected character

It seems that the Invoice date is null. Are there other settings that I should follow? Downloading the invoice will also produce an error because of the Invoice date.

EDIT: I edited the Laravel Invoice class (vendor\laravel\laravel\cashier\Invoice.php) to print the real date and it turns out, the invoice date is NULL.

 * Get a Carbon date for the invoice.
 * @param  \DateTimeZone|string  $timezone
 * @return \Carbon\Carbon
public function date($timezone = null)
    echo("HERE <br />");
    $carbon = Carbon::createFromTimestampUTC($this->invoice->date);

    return $timezone ? $carbon->setTimezone($timezone) : $carbon;

The var_dump($this->invoice->date); returns NULL.

0 Answers