I am working in laravel project and i want to display my json data from url into the view dashboard.blade, And this is the sample json data:
{"response":{"result":{"Contacts":{"row":[{"no":"1","fl":[{"val":"CONTACTID","content":"144120000000079041"},{"val":"First Name","content":"Tata"},{"val":"Last Name","content":"Nyerere"},{"val":"Email","content":"nyereredaniel@gmail.com"},{"val":"Account Name","content":"null"},{"val":"Phone","content":"255652400670"},{"val":"Mobile","content":"null"}]},{"no":"2","fl":[{"val":"CONTACTID","content":"144120000000069001"},{"val":"First Name","content":"Daniel"},{"val":"Last Name","content":"Nyerere"},{"val":"Email","content":"nyereredaniel@hotmail.com"},{"val":"Account Name","content":"null"},{"val":"Phone","content":"255754897505"},{"val":"Mobile","content":"null"}]},{"no":"3","fl":[{"val":"CONTACTID","content":"144120000000065068"},{"val":"First Name","content":"Lawrence"},{"val":"Last Name","content":"Zoho"},{"val":"Email","content":"support@zohosupport.com"},{"val":"ACCOUNTID","content":"144120000000065066"},{"val":"Account Name","content":"Zoho"},{"val":"Phone","content":"1 888 900 9646"},{"val":"Mobile","content":"null"}]}]}},"uri":"/api/json/contacts/getrecords"}}
And here is my Controller method:
public function getDashboard()
{
$url = "";
$json = file_get_contents($url);
return view('dashboard')->with('leads', json_decode($json, true));
}`
And here is my dashboard.blade that displays the json data on my view page:
@foreach($leads['row'] as $rows)
First Name:
Last Name:
Email:
Phone:
@endforeach
,The problem comes when i run the application .I get the error:
ErrorException in dabf77fa034da98b06cb6ab2d3557085c7095724.php line 25:
Undefined index: row (View: C:\wamp\www\ZOHOCRMWIKI\resources\views`\dashboard.blade.php).
Can anyone assist me on the issue and how to write the foreach in dashboard.blade file as i have spent time to solve this I will appreciate your help guys. Thanks in advance`
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire