hkucuk
hkucuk

Reputation: 345

Laravel, response json data into controller and make json_decode into view

I want to make this, 1. Controller return json data to view

$data =  Response::json(array('status' => FALSE, 'code' => 205, 'message' => 'Deneme', 'data' => null), 200 );

    return View::make('site.index.index')->with('data', $data);

2. view will make decode this data and will use.

{{ $data2 = @json_decode($data)  }}

{{ var_dump($data2) }}

json data going into view but don't decoding on array.

How can decode this data?

Upvotes: 1

Views: 1862

Answers (1)

itachi
itachi

Reputation: 6393

$data = json_encode(array('status' => FALSE, 'code' => 205, 'message' => 'Deneme', 'data' => null));

return View::make('site.index.index')->with('data', $data);

Upvotes: 1

Related Questions