【发布时间】:2016-06-13 18:26:19
【问题描述】:
我正在尝试将数组的值从一种方法传递到 Laravel 中的另一种方法。基本上我有一个名为 orderingSubmission 的方法,它从 Ajax POST 执行中接收一个数组(该部分工作正常),但是我试图将数组值传递给另一个名为 orderingSubmissionReceipt 所以我终于可以在订单摘要页面上呈现视图了。我正在使用会话,但它们似乎不起作用。谁能告诉我我错过了什么?
这是我的 route.php
Route::get('/', function() { return redirect('home'); });
Route::get('home', 'HomeController@home');
Route::post('home', 'HomeController@activateCustomer');
Route::post('order-summary', 'HomeController@OrderingSubmission');
Route::get('order-summary', 'HomeController@orderingSubmissionReceipt');
HomeController.php
public function orderingSubmission(Request $request)
{
$allValues2 = $request->get('users'); // This code works fine. It gets the array
Log::info('This is orderingSubmission.....: ' . print_r($allValues2, true));
Session::set('allValues2',$allValues2);
}
public function orderingSubmissionReceipt()
{
$allValues3 = Session::get('allValues2'); // This code is not getting the session value
Log::info('This is orderingSubmissionReceipt.....: ' . print_r($allValues3, true));
return view('order-summary', [
'people' => $allValues3
]);
}
【问题讨论】: