【发布时间】:2020-10-10 15:51:44
【问题描述】:
我收到 JSON 响应
@foreach($logs as $log)
<div class="modal-body">
{{ $log->general }}
</div>
<div class="modal-body">
{{ $log->response_headers }}
</div>
@endforeach
响应的结构不像我所做的那样现在是可读的
General
{
"host": "abcd-io.test",
"path": "api/v1/companies/hello.com",
"request_ip": "127.0.0.1"
}
response_headers
{
"X-Powered-By": [
"Express"
],
"Access-Control-Allow-Origin": [
"*"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"4857"
],
"ETag": [
"W/\"12f9-UhKH0rSAm7BiHIeW5pbrH1gphXs\""
],
"Date": [
"Sat, 20 Jun 2020 12:51:28 GMT"
],
"Connection": [
"keep-alive"
]
}
控制器
public function index() {
$logs = Log::where('user_id',auth()->user()->id)
->orderBy('created_at', 'DESC')->get();
return view('api.logs', compact('logs'));
}
我希望分别显示host和abcd-io.test
我尝试使用{{ $log->general['host'] }},但没有成功
【问题讨论】:
-
添加你的控制器代码
-
@TalhaF。用控制器更新了代码
标签: php json laravel laravel-blade