I'm trying to post data from controller to view, basically when page loads user sees the form and when it get submits, it returns the data. I'm not sure what I'm doing wrong. I have tried the following to returns the data
Return methods tried:
return view('welcome',['all_data'=>$all_data]);
return view('welcome')->with('all_data', $all_data);
return view('welcome')->with('data', json_decode($data, true));
return View::make('welcome', array('all_data'=>$all_data));
Controller:
public function getStatus(Request $request){
//SQLQuery which returns $all_data
$all_data = json_encode($data);
return view('welcome', compact('all_data'));
}
Route:
Route::get('/', function () {
return view('welcome');
});
Route::post('/getstatus', 'GetApplicationStatusController@getStatus');
View:
@foreach ($all_data as $data)
<td id="appid">{{$data->appid}}</td>
<td id="firstname">{{$data->firstname}}</td>
<td id="middlename">{{$data->middlename}}</td>
<td id="lastname">{{$data->lastname}}</td>
<td id="action">{{$data->action}}</td>
@endforeach