Search code examples
phpcontrollerhttp-status-code-404laravel-5restful-url

Laravel 5 returns blank page for a method which does not exist


I created a RESTful controller with artisan make:controller and i am using resource method at my routes.php, here is my routes.php:

Route::resource('page', 'PageController');

I don't have any edit method at my controller (i removed it) so if i hit this URI:

http://laravel.dev/page/{id}/edit

Laravel should return a 404 page but instance it returns a blank page.

how can i make it return 404 response for a method which does not exist?


Solution

  • Problem was with the permission of storage directory but I'm wondering why it's just happened at this controller? i had no problem with getting errors from other part of the application.

    anyway first i changed the permission of the storage directory:

    sudo chmod -R 777 storage/
    

    then i got the MethodNotFoundException, so i add the only to the third part of resource method to customize my routes and every thing is fine:

    Route::resource('page', 'PageController', ['only' => ['index', 'show'] ]);
    

    now its throw NotFoundHttpException.