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 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

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -