I have 3 layers of entities, of which I only want the third object. but based on information from the first two.
For example, I have a factory that makes cars, and each car has a type of wheel. I want all the wheels manufactured by a factory.
I do not know how to do this using eloquent, the only idea I had was to do several hasMany to get this data. but I fear it is not the most efficient way because I will end up getting data that will not be used.
I tried this but it did not work out as well as I wanted.
DB::raw('select results from hectars h,consultas c,results r where h.id_fazendeiro=? and h.id=c.id_hectar and c.id = r.id_consulta',[$id]);