php - Count my totals up - Laravel 5.2 -
i have "orders" table holds totals in each row every order in shop. need count totals every single row grand total. how set query in laravel?
my orders table:
my function:
public function index() { // orders in db $orders = order::all(); // doesnt work, counts rows $count_total = db::table('orders')->select('count(total)')->count(); dd($count_total); // carts in db $carts = cart::all(); return view('admin.pages.index', compact('orders', 'carts', 'count_products')); }
you can use eloquent way, doing can total sum of column.
$total = orders::sum('total'); echo "<pre>"; print_r($total); echo "<pre>";
Comments
Post a Comment