Home » Php » javascript – how to display specify object value from JSON in laravel table view blade

javascript – how to display specify object value from JSON in laravel table view blade

Posted by: admin February 25, 2020 Leave a comment

Questions:

i manage to display certain value but not manage for another value in blade table…I want to display value

description

which is inside

irel__com_access_level

from my json response

….here is my response json with code

{
            "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": "[email protected]",
            "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"
            },

        },

in my controller

 public function index()
    {

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

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

    }

my blade file

 @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>
How to&Answers:

in your Controller do this:

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]);

    }

then in your Blade you can reach this in this way:

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