Support the ongoing development of Laravel.io →
posted 5 years ago
Laravel
Last updated 2 years ago.
0
moderator

A general tip if a route can't be found is to run the php artisan laravel:route command and look for your routes.

The first look at your code is that it should exist.

0

Hi Tobias,

First of all thanks for your answer.

I had reviewed routes with this command and they doesn´t appear, that is the problem. But, how can I add the Route::resource code to have an existing resource routes?

0
moderator

Can you try php artisan route:clear it can be that you have the routes cached (with php artisan route:cache ) then the routes will not be loaded from the routes file but from the cache.

0

Hi again Tobias,

I have already executed route:clear command and the problem still happens. :S

0

Sure,

| Domain | Method | URI | Name | Action | Middleware |

| | GET|HEAD | / | | Closure | web |

| | GET|HEAD | api/user | | Closure | api,auth:api |

Last updated 5 years ago.
0

go to your PostController and inside index() method if you have created controller with resource u can see index() method there and there you return view('index'); i hope it will work. else you have to create route::get('/',Controller_Name@index) and then inside index you have to put the return view('/index')

0

That is my index method code. I had wrote it before the realize problem:

public function index()

{

$products = Product::latest()->paginate(5);

    return view('products.index', compact('products'))
        ->with('i',(request()->input('page', 1)-1)*5);

}

I have created Route::resource, so it shouldn´t be necessary to create the routes using Route::get code.

Last updated 5 years ago.
0

Solved, I feel a little bit stupid...

I wrote this code:

Route::get('/', function () {
    return view('welcome');
		
		Route::resource('products', 'ProductController');
});

Instead of:

Route::get('/', function () {
    return view('welcome');
});

Route::resource('products', 'ProductController');
Last updated 5 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Miguel cancellara Joined 3 Sep 2019

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.