【问题标题】:laravel controller restfull and formlaravel 控制器 restfull 和 form
【发布时间】:2014-11-06 17:21:55
【问题描述】:

我想发布一个带有restfull语法“auth/inscription”的注册表单,但它不起作用,它给了我这个错误

InvalidArgumentException 
Route [auth/inscription] not defined.

路线:

 Route::controller('auth', 'AuthController');

控制器:

public function postInscription()
{
    if ($this->create_validation->fails()) {
        return Redirect::route('auth/inscription')
        ->withInput()
        ->withErrors($this->create_validation->errors());
    } 
    else 
    {
        $this->user_gestion->store();

        return Redirect::route('home')
            ->with('ok','L\'utilisateur a bien été créé.');
    } 
}

inscription.blade.php: (只有我们需要的那一行)

{{ Form::open(array('url' => 'auth/inscription', 'method' => 'post', 'class' => 'form-horizontal         panel')) }}

所以,错误:

InvalidArgumentException 
Route [auth/inscription] not defined.

不明白... 有人可以帮我吗?

【问题讨论】:

    标签: rest authentication laravel laravel-routing


    【解决方案1】:

    这是因为 'auth/subscription' 不是命名路由。

    您可以在控制器路由的第三个参数中传递一组名称/方法。

    只需将行更改为:

    return Redirect::to('auth/inscription');
    

    【讨论】:

      【解决方案2】:

      错误可能出现在您的退货声明中,因为您的登记失败。您是否定义了可以重定向用户的 getInscription-Method?

      return Redirect::route('auth/inscription')
      

      【讨论】:

      • 是的,这里是: public function getInscription(){ return View::make('inscription'); }
      猜你喜欢
      • 2014-11-09
      • 1970-01-01
      • 2020-11-01
      • 2023-03-27
      • 2017-03-05
      • 1970-01-01
      • 2021-07-10
      • 1970-01-01
      • 2021-07-31
      相关资源
      最近更新 更多