Laravel 5.1 MethodNotAllowedHttpException - 注册

时间:2017-10-18 10:43:44

标签: laravel laravel-5.1

我有注册问题。当用户完成注册后,他将收到此错误消息 - RouteCollection.php第219行中的MethodNotAllowedHttpException。如果您遇到导致此错误的问题,是否可以检查代码。

01。)Routes.php



/**
     * Guest only visit this section
     */
    Route::group(['middleware' => 'guest'], function () {
        Route::get('account/login', ['as' => 'login', 'uses' => 'Auth\LoginController@getLogin']);
        Route::get('auth/{provider}', 'Auth\LoginController@getSocial');
        Route::get('auth/{provider}/callback', 'Auth\LoginController@getSocialCallback');
        Route::get('registration/{provider}', 'Auth\RegistrationController@getSocialRegister');
        Route::get('account/registration', ['as' => 'registration', 'uses' => 'Auth\RegistrationController@getIndex']);
        Route::get('registration/activate/{username}/{code}', 'Auth\RegistrationController@validateUser');
        Route::get('password/email', ['as' => 'password.reminder', 'uses' => 'Auth\PasswordController@getEmail']);
        Route::get('password/reset/{token}', 'Auth\PasswordController@getReset');
    });

    /**
     * Guest Post form with csrf protection
     */
    Route::group(['middleware' => 'csrf:guest'], function () {
        Route::post('account/login', 'Auth\LoginController@postLogin');
        Route::post('registration/{provider}', 'Auth\RegistrationController@postSocialRegister');
        Route::post('password/email', 'Auth\PasswordController@postEmail');
        Route::post('password/reset/{token}', 'Auth\PasswordController@postReset');
        Route::post('account/registration', 'Auth\RegistrationController@postIndex');
        Route::get('image/freefiles/{slug}', ['as' => 'images.freefiles', 'uses' => 'ImageController@getFreeFiles']);
    });




02。)login.blade.php



   <form action="{{url('/registration')}}" method="POST">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <div class="sminputs">
                                        <div class="input full">
                                            <label class="string optional" for="username">username*</label>
                                            <input class="string optional" maxlength="255" id="username" name="username" placeholder="username" type="text" size="50" />
                                        </div>
                                    </div>
                                    <div class="sminputs">
                                        <div class="input full">
                                            <label class="string optional" for="email">Email*</label>
                                            <input class="string optional" maxlength="255" id="email" name="email" placeholder="Email" type="email" size="50" />
                                        </div>
                                    </div>
                                    <div class="sminputs">
                                        <div class="input string optional">
                                            <label class="string optional" for="password">Password *</label>

                                            {!! Form::password('password',['class'=>'form-control input-lg','placeholder'=>t('Enter Password'),'autocomplete'=>'off','required'=>'required']) !!}
                                        </div>
                                        <div class="input string optional">
                                            <label class="string optional" for="password_confirmation">Repeat password *</label>

                                            {!! Form::password('password_confirmation',['class'=>'form-control input-lg','placeholder'=>'Confirm Password','autocomplete'=>'off','required'=>'required']) !!}
                                        </div>
                                    </div>
                                    <div class="simform__actions">
                                        <input class="sumbit" name="commit" type="submit" value="Create Account" />

                                        <span class="simform__actions-sidetext">By creating an account you agree to our <a class="special" href="#" target="_blank" role="link">Terms & Privacy</a></span>
                                    </div>
                                </form>
&#13;
&#13;
&#13;

03。)login_beta.blade.php

&#13;
&#13;
  <form action="{{url('registration')}}" class="contact_form2" method="POST">
            <h1 style="text-align: center">Create Your Account</h1>
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <ul id="usn_eml">
                <li>
                    <input type="text" maxlength="255" id="username" name="username" class="textbox1"
                    placeholder="Your username..." required/>
                    <span class="form_hint">Enter username</span>
                </li>
                <li>
                    <input type="email" maxlength="255" id="email" name="email" class="textbox1"
                    placeholder="Your email..." required>
                    <span class="form_hint">Enter email...</span>
                </li>
                <li>
                    {!! Form::password('password',['class'=>'textbox1','placeholder'=>t('Enter Password'),'autocomplete'=>'off','required'=>'required']) !!}
                    <span class="form_hint">Your password...</span>
                </li>
                <li>
                    {!! Form::password('password_confirmation',['class'=>'textbox1','placeholder'=>'Confirm Password','autocomplete'=>'off','required'=>'required']) !!}
                    <span class="form_hint">Confirm password...</span>
                </li>
				<ol style="clear: both; display: block; padding-top: 17px;">
               
                <div class="form-group">
                    <script src='https://www.google.com/recaptcha/api.js'></script>

                    <div class="g-recaptcha" data-sitekey="xxxx"></div>
                </div>
            
			   </ol>
                <input name="commit" type="submit" value="Create Account"/>
                
            </ul>

            <style>
                #usn_eml {
                    width: 50%;
                    display: block;
                    margin: auto;
                }
            </style>

            

            <div class="tos">
                By creating an account you agree to our <a
                class="special" href="http://pixsector.com/p/terms-of-service" target="_blank" role="link">Terms &
                Privacy</a>
            </div>

            <div class="already_member">
                <p>Already a member? Please<a id="getSignInDiv" href="#"> Sign In</a></p>
            </div>
        </form>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

你有两条路由使用相同的网址,所以你似乎试图发布到获取路由,你应该给你的路由命名,所以你没有这个问题,如下所示:

 Route::post('registration/{provider}', ['as'=>'registration.store', 'uses'=>'Auth\RegistrationController@getSocialRegister']);

然后在你的刀片中,你可以这样称呼你的行动

action="{{ route('registration.store', ['provider' => $provider]) }}"

你没有在你的刀片中传递任何参数,而你的路线期待一个;