0
votes

routes.php

   <?php
    Route::group(['middleware' => 'api', 'prefix' => 'sale', 'namespace' => 'Modules\sale\Http\Controllers'], function()
    {
        Route::get('/', 'SaleController@index');
        Route::resource('sale','SaleController');
    });

I'm trying to do request to my controller, but it's returning me the following error .

MethodNotAllowedHttpException

3
Check your method if it is post or get.aldrin27
Can you post the request as well?Ijas Ameenudeen
Try http:127.0.0.1:8000/public/roomaldrin27
Can you include your SalesController ?Jie

3 Answers

0
votes

Without seeing the HTML, it's hard to tell why it went wrong. Here is one of the possible reasons. Maybe you missed method="get" in your html form.

0
votes

Add a post route, most likely your form is posting to the route

 Route::get('/', 'RoomController@displayIndex');//change the get to return a view or delete it 
 Route::post('/', 'RoomController@index');
0
votes

I think you are using one controller action for two different URLs.

1) siteurl/

2) siteurl/sale

both above URL want to access same controller action (index) as when you define resource route file, it will use index action for listing sale Model.

Reference : https://scotch.io/tutorials/simple-laravel-crud-with-resource-controllers