Saturday, March 18, 2017

Quering best result in terms of different columns in laravel eloquent orm?

I have a table something like this.enter image description here

For example we have the name_id=22 and the geometrie_id=4. Now i want to query the best result in terms of aussehen,farbe,deformation,geruch and texture for that name_id and geometrie id.

I can get all the results by

$nam=Ergebnisse::where('name_id', $name)
         ->where('geometrie_id', $geometrie)
         ->get();

for the above query we have the best result at id=3 that is (1,1,1,1,1) but it would not be same all the time, may be the best result will be (1,2,4,1,1). How can i query in term of that. I think its a kind of decision tree.If any one can help me in this?



via Hassan Haroon

Advertisement