显示包含对象值为

时间:2017-12-23 22:47:23

标签: php laravel object eloquent

我有一个包含列'事务'的数据库表。包含对象值。

在视图文件中,dd($ receipts->事务)是: -

"{"cancelled":"0","hash":"5a3ecdf73225d","order_id":"134","tx_date":"24-December-2017 00:43:45","tx_amt":"180.0000","Result":"CAPTURED","PaymentID":"3031646430073580","PostDate":"1224","TranID":"6582408430073580","Auth":"657402","Ref":"735800425124","tx_id":"1781","tx_mode":"KNET","tx_status":""}"

当我尝试打印tx_date时 - > {{$ receipts->交易 - > tx_date}}

给出错误: 试图获得非对象的属性

我尝试了以下内容:

@php
$receipts->transaction = (object) $receipts->transaction;
@endphp

然后 {{$ receipts->交易 - > tx_date}}

1 个答案:

答案 0 :(得分:0)

发生这种情况是因为$ receipts->事务是一个数组,而不是一个对象。

而不是:

$receipts->transaction->tx_date

使用:

$receipts->transaction['tx_date']