0
I have a route that has parameters:
Route::get('/cursos/{area?}/{categoria?}', 'SiteController@cursosFiltro')->name('cursos');
In the URL to passing the Slug of these past terms:
{{ url("cursos?categoria=$categoria->slug&area=$area->slug")}}
Now, I need to get the id’s on those slugs from the Controller. I need to take the CATEGORY table the id of the Slug coming in the url and take the table AREA tb and assign this value to a variable.
I did so:
public function cursosFiltro(Request $request, $area = '', $categoria = ''){
$categoria = ($request->categoria);
$area = ($request->area);
$idCategoria = CategoriaCurso::where('id_categoria_curso', $categoria)->get();
$idArea = AtuacaoArea::get('id_atuacao_area', $area)->get();
return view('site.cursos.cursos')
->with(compact('cursos', 'idArea', 'idCategoria'));}
It’s not working. I can’t get the Slug id from the url. How to do?
Are you storing Slug in a database? What’s the column called? Or dynamically create?
– Miguel
Yes! stored in the @Miguel database
– Junio Araujo
Try this:
CategoriaCurso::where('col_do_slug', $request->categoria)->first();
– Miguel