Laravel收银员发票日期发布 [英] Laravel Cashier Invoice Date Issue
问题描述
我正在使用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屋!