Level 73
You can use something like
DB::table('reviews')
->select(DB:raw('TRUNCATE(AVG(rating),2)')
->where('restro_id', 9)
->get()
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
SELECT TRUNCATE(AVG(rating),2) FROM `reviews` WHERE restro_id=9
I want to write above query in laravel, How can I achieve it ?
You can use something like
DB::table('reviews')
->select(DB:raw('TRUNCATE(AVG(rating),2)')
->where('restro_id', 9)
->get()
Please or to participate in this conversation.