Laravel收银员发票日期发布 [英] Laravel Cashier Invoice Date Issue

查看:53
本文介绍了Laravel收银员发票日期发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel 5.8和Laravel Cashier.当我尝试显示用户发票列表时,我使用了以下代码:

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)
    <tr>
        <td>{{ $invoice->date()->toFormattedDateString() }}</td>
        <td>{{ $invoice->total() }}</td>
        <td>
            <a href="/user/invoice/{{ $invoice->id }}">Download</a>
        </td>
    </tr>
@endforeach

但是,行 $ invoice-> date()-> toFormattedDateString()给出了错误:

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.

我编辑了Laravel发票类(vendor \ laravel \ laravel \ cashier \ Invoice.php)以打印真实日期,事实证明,发票日期为NULL.

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 />");
    var_dump($this->invoice->date);
    exit();
    $carbon = Carbon::createFromTimestampUTC($this->invoice->date);

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

var_dump($ this-> invoice-> date); 返回NULL.

推荐答案

只需替换:

$this->invoice->date

收件人:

$this->invoice->created

这篇关于Laravel收银员发票日期发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆