我想对我的数据表使用对象数组而不是查询,但它不起作用,因为它不是来自查询集合。
我的数组就像这样
public function query(){
$santri = DataSantri::select('data_santri.*','id_vc')
->join('vc','data_santri.id_user','=','vc.id_user')
->whereIn('status_kegiatan',['ziyadah','mutqin','tahsin'])
->get();
foreach($santri as $row){
$pl = PaymentList::where('is_active',1)
->where('angkatan',$row->angkatan)
->where('payment_list.payment_time','bulanan')
->get();
$totalPl = DB::table('payment_list')
->where('is_active',1)
->where('angkatan',$row->angkatan)
->where('payment_list.payment_time','bulanan')
->sum('payment_price');
$pa = PaymentAddon::where('nis',$row->nis)->get();
$totalPa = DB::table('payment_addon')
->where('nis',$row->nis)
->sum('payment_price');
$data[] = array(
'nis' => $row->nis,
'id_vc' => $row->id_vc,
'nama_lengkap_santri' => $row->nama_lengkap_santri,
'jk' => $row->jk_santri,
'data_pembayaran_bulanan' => $pl,
'data_pembayaran_tambahan' => $pa,
'total' => $totalPl + $totalPa
);
}
$collect = collect($data);
return $this->applyScopes($collect);
}
它返回这样的错误
Method Illuminate\Support\Collection::getQuery does not exist.
我该如何解决这个错误?谢谢你