2
I’m passing parameters on a Route using Laravel 5.8 like this:
Route::get('/cursos/{id_categoria_curso}/{id_atuacao_area}', 'SiteController@cursosFiltro')->name('cursos');
I want to make the Controller execute whether the values are passed or not. For example: A link that will pass the Two parameters, another link that will pass only One and a third link that will not pass any?
You can do this in Rota and Controller or I’ll have to make 3 controllers one for each situation?
You will always load the same View. Having or not parameters.
So now it looks like this: If you pass the two parameters it works. If you pass 1 or none does not load the courses. the filter ta thus: $courses = Course::Where('id_categoria_course', $id_categoria_course) ->Where('id_actuaca_area', $id_actuacao_area) ->get(); Return view view('site.cursos.courses', Compact('courses', 'categories', 'areas'));
– Junio Araujo
you need to work the logic of your controller.
– gmsantos
i answered my question with a question on IF. You can help me?
– Junio Araujo
in this case would be a new question @Junioaraujo
– gmsantos
related: https://pt.meta.stackoverflow.com/questions/1682/o-que-fazer-quando-o-o-p-muda-sua-question/1684#1684
– gmsantos