我试图验证表单中的一些数据,并将用户重定向到任何错误的页面。我的代码不会重定向到任何路线。我的所有路由的路由工作正常。我使用Input :: all()回显输入,并且它具有用户输入。验证器也可以工作。我不知道到底发生了防止工作Laravel没有重定向到路由
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";
}
重定向::路线这是先于购买后的方法的代码:
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'文件内容吗? – lowerends