RouteNolAllowed(array('GET','HEAD'))在RouteCollection.php laravel 5.0中

时间:2015-07-03 22:02:43

标签: laravel laravel-5

我想在提交表单时登录,但收到错误。

表单代码如下:

{!! Form::open() !!}
                {{ $errors->first("parentPassword") }}<br />
                <div>
                    <legend>Parent</legend>
                    Email<br>
                    <input type="email" id="email" name="parentEmail" required>
                    <br>
                    Password<br>
                    <input type="password" name="parentPassword">
                    <br><br>
                </div>
                {!!Form::submit('Submit',array('class' => 'btn btn-outline btn-primary')) !!} </fieldset>
                {!! Form::close() !!}

控制器代码如下:

 App\Http\Controllers;

 use Illuminate\Support\Facades\Redirect;
 class loka extends Controller
{
public function login()
{
    if ($this->isPostRequest()) {
        $validator = $this->getLoginValidator();

        if ($validator->passes()) {
            $credentials = $this->getLoginCredentials();

            if (Auth::attempt($credentials)) {
                return redirect()->intended('/');
            }

            return Redirect::back()->withErrors([
                "parentPassword" => ["Credentials invalid."]
            ]);
        } else {
            return Redirect::back()
                ->withInput()
                ->withErrors($validator);
        }
    }

    return view("signup.index");
}

protected function isPostRequest()
{
    // return Request::isMethod('post');
}

protected function getLoginValidator()
{
    return Validator::make(Request::all(), [
        "parentEmail" => "required",
        "parentPassword" => "required"
    ]);
}

  protected function getLoginCredentials()
  {
    return [
        "parentEmail" =>  Request::input("parentEmail"),
        "parentPassword" =>  Request::input("parentPassword")
       ];
    }
 }

路线如下:

Route::patch("/index", [
"as"   => "login/index",
"uses" => "loka@login"
]);

0 个答案:

没有答案