Passionate Engineer
Passionate Engineer

Reputation: 10422

Laravel 404 not found on resource

I created files using Way generator resource and then used below to map resources with URLs.

Route::resource('adpacks', 'AdpacksController'); 

However, it seems though http://laravel.dev/adpacks is returning 404 not found error. But others such as http://laravel.dev/adpacks/create and http://laravel.dev/adpacks/1/edit seems to be working fine.

Is there a reason why index isn't working at all?

Also GET /adpacks - adpacks.index - AdPacksController@index is showing on registered routes list in CLI

Upvotes: 0

Views: 5757

Answers (4)

anto
anto

Reputation: 1

Sometimes you need to check the parameters in your controller

Example:

If you have the type of code below, a 404 error will happen:

public function edit(Object $object)
    {
}

So you can go to your controller and change it:

public function edit($id)
    {
}

You can try to explore if your code enter in the Route echoing a "hello" for example:

Route::post('/audio', function () {
        dd("hello);
    });

This helped me thus maybe can help you.

Upvotes: 0

webfuelcode
webfuelcode

Reputation: 97

Just here to confirm, because it happened with me for almost 3-4 days. And no laravel community helped in this.

So anyone seeing this, hope to get help from this experience.

--For me, no replacing the lines worked though it could be helpful for some reason and people should try it. But I just renamed the route and it worked.

Upvotes: 0

Abdur Rahman
Abdur Rahman

Reputation: 783

Looks like other route override that route.

Please take the line at the top of the route file.

Route::resource('adpacks', 'AdpacksController'); 

Upvotes: 0

Roelof Hoeksema
Roelof Hoeksema

Reputation: 23

A bit late, but for anyone encountering the same problem: I found the solution:

Turns out my route was interfering with some other routes. I moved the line further up the web.php file, and it worked. Renaming the route also bypasses the problem.

Upvotes: 2

Related Questions