mardi 25 décembre 2018

how to sort multiple added column

i have tables which are relationships between them Tours and Comments. In view i have filter 1) new 2) popular 3) old. I want to select popular by sum of columns(let's assume col_a, col_b, col_c, col_d) in Comments which are users were left rate for this Tour here is my code:

$tours = $tours->comment()->select(DB::raw('housing, destination, nutrition, transport, price AS total_points'))->orderBy('total_points', 'desc');

$tours should be as a object because at the end i sen this result with paginate. Please help me. thanks in advance and sorry for my english



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire