Nanourgo Pierre
Nanourgo Pierre

Reputation: 11

Route [course] not defined

I created a resource controller. The problem is when I code a route in my view, the browser displays Route [course] not defined. I run the php artisan route:list command and I realize that the route does not exist in the route list.

The controller method

public function index()
{
    $courses = Course::where('user_id', Auth::user()->id)->paginate(10);

    return view('teacher.teachercourse.courses', compact('courses'));
}

The web.php code

Route::get('course', 'CoursesController@index')->name('course');
Route::get('course', 'CoursesController@create')->name('course.create');

The link

<li><a href="{{ route('course') }}">Courses</a></li>

Upvotes: 0

Views: 802

Answers (1)

Juan David Gonzalez
Juan David Gonzalez

Reputation: 19

As both routes are get you can't use the same uri:

change the uri example:

Route::get('courses', 'CoursesController@index')->name('courses.index');
Route::post('course/create', 'CoursesController@create')->name('course.create');

Upvotes: 1

Related Questions