【发布时间】:2014-09-16 16:34:14
【问题描述】:
我正在尝试验证表单中的一些数据并将用户重定向到页面,如果有任何错误。我的代码不会重定向到任何路线。我所有路线的路由都正常工作。我用 Input::all() 回显了输入,它确实有用户输入。验证器也可以工作。我不确定究竟是什么阻止了 Redirect::route 工作
public function postPurchase()
{
$validator = Validator::make(Input::all(), array(
'condition' => 'required',
'memory' => 'required',
'color' => 'required',
'accessories' => 'required',
'shipping' => 'required'
));
// $input = Input::all();
// dd($input);
if ($validator->fails()) {
// echo "string";
return Redirect::route('home');
} else {
echo "this succedded";
}
//Get prices, item id, etc and send user to checkout page
// echo "Get prices, item id, etc and send user to checkout page";
}
这是 postPurchase 方法之前的代码:
public function getPurchase()
{
return View::make('general.purchase');
}
public function getCheckout()
{
return View::make('general.checkout');
}
public function postPurchaseCheck()
{
$input = Input::all();
$this->input = $input;
if (Input::get('buy')) {
$this->postPurchase();
}
elseif (Input::get('cart')) {
$this->postAddCart();
}
}
【问题讨论】:
-
您是否收到任何错误消息?你也可以发布你的
routes.php文件内容吗?