前提・実現したいこと
コードの通りselect()の中に何行かDB::raw()で値を取得しているのですが、
キャンセル数の所だけwhere('cancel_id', '<>', 0)もかけた値を取得したいので
後ろにくっつけたんですがエラーが出てしまいます。
何かいい書き方はありますでしょうか?
発生している問題・エラーメッセージ
Call to undefined method Illuminate\Database\Query\Expression::where()
該当のソースコード
laravel
1 $date_sales = Sales_data::select( 2 //総合計 3 DB::raw('SUM(total_amount) as total_amount'), 4 //税合計 5 DB::raw('SUM(tax_amount) as tax_amount'), 6 //原価計 7 DB::raw('SUM(cost_amount) as cost_amount'), 8 //販売点数 9 DB::raw('SUM(quantity_total) as quantity_total'), 10 //キャンセル数 11 DB::raw('SUM(quantity_total) as cancel_total')->where('cancel_id', '<>', 0) 12 //取引数 13 // DB::raw('COUNT(order_id) as order_amount'), 14 //値引き合計 15 // DB::raw('SUM(discount_total) as discount_total'), 16 //返品点数 17 // DB::raw('SUM(return_quantity_amount) as return_total') 18 )->where('sales_date', $date)->where('customer_id', 'not like', '0%')->get();
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/05 02:59