简体   繁体   中英

Laravel route not defined but it clearly is

I keep getting the following error in Laravel 5.3:

Route [clients] not defined. (View: /srv/users/serverpilot/apps/project-sytem/resources/views/partials/sidebar.blade.php) (View: /srv/users/serverpilot/apps/project-sytem/resources/views/partials/sidebar.blade.php) (View: /srv/users/serverpilot/apps/project-sytem/resources/views/partials/sidebar.blade.php)

Here is my routes file:

Route::group(['middleware' => 'auth'], function () {
    Route::get('/', 'ProjectController@index')->name('projects');
    Route::get('/projects', 'ProjectController@index')->name('projects');
    Route::resource('projects', 'ProjectController');


    Route::get('/clients', 'ClientController@index')->name('clients');
    Route::resource('clients', 'ClientController');

});


Auth::routes();

Route::get('/home', 'HomeController@index');

In my sidebar.blade.php I have links to my routes like this:

<li>
   <a href="{{ route('projects') }}"><i class="fa fa-archive" aria-hidden="true"></i> Projects</a>
</li>
<li>
   <a href="{{ route('clients') }}"><i class="fa fa-users" aria-hidden="true"></i>Clients</a>
</li>

I don't see where I'm going wrong, my projects route works just fine and I've done it the exact same way. Any ideas what's going wrong with my clients route?

Route::resource overwrites @index route with clients.index , that's why you're getting the error.

Remove clients route completely and use clients.index route name in the view:

<a href="{{ route('clients.index') }}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM