繁体   English   中英

如何在laravel表视图刀片中显示来自JSON的指定对象值

[英]how to display specify object value from JSON in laravel table view blade

我设法在刀片表中显示某些值但没有管理另一个值...我想显示值

description

这是里面

irel__com_access_level

来自我的 json 响应

....这是我的响应 json 代码

{
            "ID": "cust1",
            "PWD": "W6ph5Mm5Pz8GgiULbPgzG37mj9g=",
            "NICK_NAME": "CUST1",
            "PWD_INVALID_HIT": "0",
            "PWD_CREATE_DT": "2019/07/22 15:57:15",
            "INSTITUTION_ID": "C01",
            "ACL_ID": "L04",
            "LOGIN_DT": "2019/07/22 15:57:15",
            "LOGIN_STS_ID": "N",
            "STS_ID": "C08",
            "TYPE_ID": "U00",
            "UPD_DT": "2019/07/22 15:57:15",
            "EMAIL_ID": "cust1@gmail.com",
            "PHONE_NO_ID": "0",
            "HP_ID": "0                        ",
            "CRT_DATE_DELETED": null,
            "irel__com_access_level": {
                "ID": "L04",
                "DESCRIPTION": "CUSTOMER",   // i want to display this
                "IS_CREATE": "Y",
                "IS_READ": "Y",
                "IS_UPDATE": "Y",
                "IS_DELETE": "N",
                "STS_ID": "R01",
                "UPD_ID": "shukrimb",
                "UPD_DT": "2018/06/26 11:15:10"
            },

        },

在我的控制器中

 public function index()
    {

        $response =  $this->client->get('getUserIndex')->getBody();
        $content = json_decode($response->getContents());

        return view('configuration.comuserprofiles.ComUserProfilesList', ['content' => $content->data]);

    }

我的刀片文件

 @foreach($content as $i=>$user)
                        @php
                            $currentRecordno = 1;
                        @endphp
                        <tr>
                            <td>{{ $currentRecordno + $i }}</td>
                            <td>{{ $user->ID }}</td>
                            <td>{{ $user->NICK_NAME }}</td>
                            <td>{{ $user->PWD_INVALID_HIT }}</td>
                            <td>{{ $user->???? }}  </td>

在您的控制器中执行以下操作:

public function index()
    {

        $response =  $this->client->get('getUserIndex')->getBody();
        $content = json_decode($response->getContents(), true); //true convert your JSON to array

        return view('configuration.comuserprofiles.ComUserProfilesList', ['content' => $content->data]);

    }

然后在您的Blade 中,您可以通过以下方式达到此目的:

$user['irel__com_access_level']['DESCRIPTION']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM