0
Create in controller
a filter that takes data from 3 different tables. Below I put the relationship and an example of what needs to happen. I am not able to create in controller
the filter that should take as reference 02 parameters that will be passed in the URL according to the user’s choice. What’s Working: When I register a Course, I put the Area of Expertise and the Category, this is working and saving well in DB.
Now what I need to do is: On the site, I have a menu that takes the Categories and a submenu that lists the Areas. Type: I stop the mouse in Graduate School and list all the areas it has. I want to filter in the view of courses only those that are Graduate and Area that he clicked.
The URL would look like this in the case, example
http://localhost/SiteNovo/public/pos-graduacao/saude
Relationships are like that:
And mine controller
are like this for now:
public function cursos($categoria, $area){
$cursos = Curso::all();
$categorias = CategoriaCurso::all();
$areas = AtuacaoArea::all();
//Filtrar cursos
return view('site.cursos.cursos',compact('cursos'));
}
Right, I made the adjustments in Route. For now I’m picking up with id’s same, but then I will pass the names to the url become clearer to the user. But I still don’t understand how SQL would look in the Method courses of the Sitecontroller class. Can you help me?
– Junio Araujo
Look @Junioaraujo if you post your 3 templates (
Entity
) is even answer, but, of course that does not have in your initial question and it is clear that it is always missing to say which relationships they have!– novic
You need to put the
Models
if so and also the class, if not the MER of the relation ! and the expected result @Junioaraujo– novic
I changed the question and put examples and prints of what I need. See if you can help me like this. I’m lost in it
– Junio Araujo
can you understand my doubt? can you help me?
– Junio Araujo
@Junioaraujo already made the edit and it’s there! basically it’s that ... need to take a look at the Laravel Eloquent documentation.
– novic
It worked like this! Thank you very much for your strength, buddy. Just taking advantage of one thing: If I want to show the names now to not get the id’s in the url, does it change a lot? I have to change course and Eloquent changes a lot?
– Junio Araujo