从位于变量Laravel eloquent查询结果中的无头数组中提取值

时间:2022-05-26 08:02:26

I do not know wheather it is a silly question or newer for you too. I am getting a search result in forms of an array in one complicated laravel eloquent query, which is stored in say "post".

我不知道这对你来说是一个愚蠢的问题还是更新的问题。我在一个复杂的laravel eloquent查询中以数组的形式获得搜索结果,该查询存储在“post”中。

When I am echoing this with

当我回应这个时

{{ $post }}

it is simply giving result like this

它只是给出这样的结果

{"id":10,"post":"first","about":"first1","user_id":4,"likes":0,"points":2,"dcoms_count":0,"views":307,"created_at":"2013-11-01 19:52:41","updated_at":"2013-11-06 13:07:37"}

But I am unable to extract one single data from this table. like when I run

但我无法从此表中提取单个数据。比如我跑的时候

{{ $post->id }}

it is giving error output. can anyone help me with this ?

它给出错误输出。谁能帮我这个 ?

1 个解决方案

#1


0  

You're trying to access it like an object, this should be the correct way:

你试图像对象一样访问它,这应该是正确的方法:

{{ $post['id'] }}

#1


0  

You're trying to access it like an object, this should be the correct way:

你试图像对象一样访问它,这应该是正确的方法:

{{ $post['id'] }}