i have created route group using middleware.It works perfectly.
But i have one issue where if i navigate url to
http://localhost/laravel-news/public/admin/add-post-new
this without login then it redirect to guest home page
but if i navigate url to
http://localhost/laravel-news/public/add-post-new
without admin in url then it return blank page.now my question is how to show page not found 404 page for that.i am using laravel 5.1
thank you
update
Route::group(['middleware' => 'admin'], function () {
Route::get('add-post-new', function () {
// dd('something');
return view('a.addPost');
});
Route::post('/add-post-new','PostsController@addPost');
Route::get('/all-post', function () {return view('a.all_post'); });
});
you set an 404 route using this.then use any view file in that route
update 13.11.2017
just make 404.blade.php page in
/resources/views/errors/
folder and that page will be shown if a route does not existinstead of laravel error for non existing route:
/resources/views/errors/
folderand then just call it with
For example make a route like this:
You can use the abort(); method and create a view into the error folder, just as explained in the documentation.
Laravel will automatically fetch the error page there and display it.
http://laravel.com/docs/5.1/errors#http-exceptions
more info http://laravel.com/docs/5.1/routing#throwing-404-errors