MethodNotAllowedHttpException in RouteCollection.php line 219:

Posted 3 years ago by pierre4854

Hi guys,

Today, I am trying to personalize my password reset form and I'm getting this error : MethodNotAllowedHttpException in RouteCollection.php line 219 How can I solve it please ? Here is my route :

    Route::get('/password/reset/form', ['as' => 'users.showEmailFormForPasswordReset', 'uses' => 'UsersController@showEmailFormForPasswordReset']);
    Route::post('/password/reset/store', ['as' => 'users.storeEmailFormForPasswordReset', 'uses' => 'UsersController@storeEmailFormForPasswordReset']);

Here is my controllers :

    /**
     * Display the password reset form
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function showEmailFormForPasswordReset(){
        $page_title = 'Mot de passe oublié';
        return view('users.reset', compact('page_title'));
    }

    /**
     * Valid the password reset form
     * @param Request $request
     * @return $this|bool
     */
    public function storeEmailFormForPasswordReset(Request $request){
        $this->validate($request, [
            'email' => 'required|email',
        ]);

        // If Email exists
        if (Auth::attempt(['email' => $request->email])){
            $token = $this->getBroker();
            $email = $request->email;
            Mail::send('users.emails.password', compact('token', 'email'), function($message) use ($request){
                $message->to($request->email)->subject('Mot de passe oublié');
            });
            return redirect('/password/reset/store')>with('success', 'Email envoyé');
        }else{
            return redirect('/password/reset/store')->withInput([$request->email])->withErrors('error', 'Addresse mail inexistante');
        }
    }

And finally here is my view :

@extends('layouts.app')

@section('content')

    <h1>Mot de passe oublié </h1>
    {!! Form::open(['url' => route('users.storeEmailFormForPasswordReset'), 'method' => 'POST']) !!}

    {!! Form::label('email', 'Veuillez entrez votre adresse email afin que nous vous envoyons un lien de confirmation : ') !!}<br>
    {!! Form::email('email') !!}<br><br>

    <button type="submit">Envoyer</button>
    {!! Form::close() !!}<br><br>
@endsection

I've already search on the Web but I didn't found something who can help me. Anyone has an idea ?

Thanks guys

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.