Search code examples
phplaravel-5laravel-5.7

Route [cource] not definedin Laravel 5.7


I have the following link in my Blade file to link cource.blade.php in the view folder.

<a href="{{ route('cource') }}" class="list-group-item">
    <i class="fa fa-credit-card"></i> <span>Cource</span>
</a>

Route

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

I get the following error message, how can I fix this problem?

Route [cource] not defined. (View: D:\exam\curd\resources\views\sidebar\sidebar.blade.php) (View: D:\exam\curd\resources\views\sidebar\sidebar.blade.php)


Solution

  • You must provide the route alias/name:

    Route::get('/cource', ['as' => 'cource', function () {
        return view('cource');
    }]);
    

    or

    Route::get('/cource', function () {
        return view('cource');
    })->name('cource');