2

how to convert simple mysql query to eloquent laravel?

in fact I want to convert down query :

 SELECT temp.* FROM
(SELECT * FROM avilableproducts ORDER BY avilableproducts.count DESC) AS temp
GROUP BY temp.products_id, temp.color
HAVING temp.products_id = 27
ORDER BY temp.count DESC;

to

$Avilableproducts = $Avilableproducts->select(DB::raw('temp.*'))
        ->from(DB::raw('(SELECT * FROM avilableproducts ORDER BY count DESC) AS temp'))
        ->groupBy(['products_id', 'color'])
        ->orderBy('count', 'desc');
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.