欢迎各位兄弟 发布技术文章
这里的技术是共享的
$customer =
Customer::select('city_name as city_name_join','store_name as store_name_join',
'customers.customer_id as customer_id', 'customer_name',\DB::raw('SUM(operation_num) as xiao_fei_num_join'),
\DB::raw('SUM(shoukuan_amount) AS xiao_fei_amounts_join'),\DB::raw('SUM(trade_yiji) as trade_yiji_join'))
->joinCity()->joinStore()->leftJoinOperation()->leftJoinShoukuan()->leftJoinTrade()->groupby("customers.customer_id");
dump($customers[0]);exit; // 下图 看到会有 customer_id 这个了
有了customer_id 之后 ,,,,才能够调用 $customers 集合里面的对象的方法
$customer =
Customer::select('city_name as city_name_join','store_name as store_name_join',
'customers.customer_id as customer_id','customers.city_id as city_id','customer_name',\DB::raw('SUM(operation_num) as xiao_fei_num_join'),
\DB::raw('SUM(shoukuan_amount) AS xiao_fei_amounts_join'),\DB::raw('SUM(trade_yiji) as trade_yiji_join'))
->joinCity()->joinStore()->leftJoinOperation()->leftJoinShoukuan()->leftJoinTrade()->groupby("customers.customer_id");
由上面代码 因为有了 'customers.city_id as city_id' ,,,所以 调用 $customers[0]->city 的值才不为空
$customer =
Customer::select('city_name as city_name_join','store_name as store_name_join',
'customers.customer_id as customer_id','customers.city_id as city_id','customer_name',\DB::raw('SUM(operation_num) as xiao_fei_num_join'),
\DB::raw('SUM(shoukuan_amount) AS xiao_fei_amounts_join'),\DB::raw('SUM(trade_yiji) as trade_yiji_join'))
->joinCity()->joinStore()->leftJoinOperation()->leftJoinShoukuan()->leftJoinTrade()->groupby("customers.customer_id");
由上面代码 正因为有了 customer_name ,,,所以 调用 $customers[0]->customer_name 的值才不为空