My problem: I am currently trying to refactor some of my controllers. Doing so I found these two routes:
Route::get('/events', [EventsController::class, 'eventsList'])->name('event-list'); Route::get('/courses', [EventsController::class, 'allCoursesList'])->name('all-events'); they show different filter options in the frontend.
What I want to do:
Example Code:
Route::get('/courses', [ 'all' => 1, EventsController::class, 'courseList' ])->name('all-events'); so having the ability to pass a variable, in this case all to my controller. EventsController So I can check with if in my controller and handle these routes differently with only one function instead of two.
With the current solutions on StackOverflow, users are using:
'uses'=>'myController@index' now if I try it like this:
Route::get('/courses', [ 'all' => 1, 'uses' => 'EventsController@CourseList' ])->name('all-events'); I get the following error:
Target class [EventsController] does not exist. Question:
What is the current, correct way, to pass a variable to a controller, from a route. In Laravel 9 and 10.
\App\Http\Controllers\EventsController@Courselist).