mercredi 18 juillet 2018

Trying to return custom 404 page Laravel

I have some problems with implementing custom 404 error.

My errorHandlerController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ErrorHandlerController extends Controller
{
    public function errorCode404()
    {
        return view('errors.404');
    }

    public function errorCode405()
    {
        return view('errors.405');
    }
}

Route:

Route::get('404',['as'=>'404','uses'=>'ErrorHandlerController@errorCode404']);

In some other controller I am trying to do this:

return redirect()->route('404');

It does not show any errors but at network console I see this(endless 302) enter image description here

But if I use

return view('errors.404');

everything works as it should.

Somebody help me please, is something wrong with my routes or else?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire