全部 我有发票模型,并且有自我参考
\\Invoice Model
public function parentInvoice()
{
return $this->hasOne('App\Invoice', 'id', 'parent_invoice_id');
}
在web.php中进行测试可以正常工作
Route::get('self', function () {
$parent = Invoice::find(132);
$children = $parent->parentInvoice->invoice_date;
echo $children;
// 2018-06-08 - it's work
});
但是在刀片上不起作用:(为什么?
not work! - <b>Date:</b> {{$invoice->parentInvoice->invoice_date)}} <br /><br />
it's work - <div class="header">Korekta faktury nr {{ $invoice->invoice_date
}}</div>
Error: Trying to get property of non-object
请帮助:(
这是我在发票模型上的功能:
private function generateCreditnoteInvoiceChangeData()
{
$config = InvoiceConfig::find(1);
$pdf = \PDF::loadView(
'pdf.creditnote_invoice_change_data',
array(
'config' => $config,
'invoice' => $this
)
);
return $pdf;
}