如何从此结构访问author
属性?
RecordDetails {#461 ▼
+record: Posts {#481 ▼
+timestamps: false
+rules: []
+table: "blog_posts"
+attachOne: array:1 [▶]
+implement: null
+attributes: array:9 [▼
"id" => 18
"title" => "Example Post 18"
"slug" => "example-post-18"
"category" => "example-category-2"
"author" => "example-author-2"
"date_time" => "2018-02-13 14:42:00"
我尝试了$componentObj->record->attributes->author
,但这不起作用 - Trying to get property of non-object
答案 0 :(得分:1)
假设包含eloquest结果的变量是 - $ dbResponse。
解决方案 -
$ dbResponse->作者;
答案 1 :(得分:0)
试试这个:
$componentObj->record->attributes[author];