Category : sum

I have two tables, a subscriptions table and a subscriptions_items table. The subscriptions table has a ‘ends_at’ column where we only want records where ‘ends_at’ is null or ‘>’ than Carbon::now() The subscription_items table has a ‘subscription_id’ column that corresponds to the ‘id’ column of the subscription table. There can be multiple subscription_items records with ..

Read more

I have three tables: super_consumers , balance_ins, recharges super_consumers table: id name ———- —- 1 A 2 B balance_ins table: id super_consumer_id amount type(1,2) — —————– —— —- 1 1 10 1 2 1 20 1 3 2 10 2 recharges table: id super_consumer_id amount status(0,1) — —————– —— —— 1 1 5 1 2 ..

Read more

I’m a newbie in Laravel and I tried to connect two tables with SUM of one column along with other columns, But it’s returned an error and I don’t know how to fix that.. Please help me to resolve the issue. Any help is appreciated … $sinv =DB::table(‘salesinvoices’) ->leftJoin(‘customers’,’customers.id’,’=’,’salesinvoices.customer’) ->select(DB::raw(‘sum((salesinvoices.grand_total)-(salesinvoices.isslnrtn_amt)) as sumgrand’),’customers.short_name’) ->where(‘salesinvoices.is_deleted’,’0′) ->where(‘salesinvoices.is_returned’,’!=’,’1′) ->where(‘salesinvoices.paidstatus’,’!=’,’1′) ..

Read more

$purchasers = DB::table(‘orders’) ->join(‘users as buyers’, ‘buyers.user_id’, ‘=’, ‘orders.user_id’) ->join(‘order_items’,’order_items.order_id’,’=’,’orders.order_id’) ->join(‘stocks’,’stocks.stock_id’,’=’,’order_items.stock_id’) ->join(‘sizes’,’sizes.size_id’,’=’,’stocks.size_id’) ->join(‘shoes’,’shoes.shoe_id’,’=’,’stocks.shoe_id’) ->where(‘orders.status’, ‘2’) ->where(‘orders.completed_date’, ‘>=’, $start) ->where(‘orders.completed_date’, ‘<=’, $end) ->select(DB::raw(‘CONCAT(buyers.last_name, ", ", buyers.first_name) as user_fullName’),DB::raw(‘order_items.quantity * shoes.price as amount’), ‘orders.order_id as order_id’ ) Sourc..

Read more

I need a get field value total sum. But I can’t and don’t know where the problem is. controller code: public function index() { $user1 = Auth::user(); $user2 = $user1->client_id; $withdraws = Withdraw::where(‘client_id’, $user2)->get(); $deposits = Deposit::where(‘client_id’, $user2)->get(); return view(‘home’)->with(compact(‘deposits’, ‘withdraws’, )); } view code: @foreach($deposits as $deposit) <td id="count-data-td">{{ $deposit->amount }}</td> @endforeach Sourc..

Read more

public function Query() { $total= User::get(‘e_id’); // dd($total); foreach($total as $totals){ [$year, $month] = explode(‘-‘, $this->month); dd($totals); $s= User::whereMonth(‘date’ , $month)->whereYear(‘date’ , $year)->where(‘e_id’ , $totals)->get()->sum(‘latehours’); dd($s); } // dd($totals); } in this code the variable $totals contain value of ‘e_id’ e.g. "a-2" which it get from form when I dd($totals) it shows value e.g. "a-2" ..

Read more

I need to add two numbers passed by the foreach in the blade view how can i add this two numbers instead of showing it as individual 333.34 333.34, I need to show it as 666.68 / 1000 AUD Here’s how blade foreach looks like @if(!empty($teams)&&count($teams)>0) @foreach($teams as $key=>$team) <table> <tr> <th>id</th> <th>Team Name</th> <th>Payment</th> ..

Read more

I have this query $installments = Installment::where(‘merchant_id’,1)->with(‘bills’)->get(); . and I need to get sum() of bill_amount column where exists in bills tables . I have tried this in controller: $paid_amount = 0; $not_paid_amount = 0 ; foreach ($installments as $installment) { $paid_amount += $installment->bills->where(‘status’,1)->sum(‘bill_amount’); $not_paid_amount += $installment->bills->where(‘status’,0)->sum(‘bill_amount’); } this work but I think it’s not ..

Read more

I have Developed an inventory management system where products table and order_details table are available. Now I want to show how many products are sold according to product_id and the summing amount to show on the blade template loop. Where Product table ID equal to order_details product_id. But unfortunately, it’s not showing. The Product Controller ..

Read more

I have two arrays. They are always the same length. If the first array element value is the same then sum of the second array element value. Example $array1 = array(1,2,2,3); $array2 = array(10,20,30,50); // I can get the sum of array1 and array2 output. $array_sum1 = array(10,50,50); $array3 = array(4,4,4,6); $array4 = array(10,20,30,50); // ..

Read more