mardi 27 novembre 2018

Object of class stdClass could not be converted to string laravel

im trying to use group by and sum in Laravel but this error code appear im new in Laravel and and this is my code

 $pemilik=DB::table("tb_simpanan")
                                     ->selectRaw('anggota_id,SUM(nominal_transaksi) as count')
                                     ->groupBy('anggota_id')
                                     ->get();  
                          $id1=1;
                          $data=DB::table('tb_master_bunga_simpanan')->where('id',$id1)->first();
                          $bunga=$data->persentase;
                          foreach($pemilik as $pem) {
                              $pem2[]=$pem->anggota_id;
                              $pem1[]=$bunga*$pem->count;     
                          }
                          $jumlah=sizeof($pem1);
                          $tanggal=date("Y-m-d H:i:s");
                          $test=3;
                        $idUser=Session::get('id');
                          $idUser1=DB::table('tb_anggota')->where('id',$idUser)->first();
                          for($i=1;$i<=$jumlah;$i++){
                              $data=[
                                    'anggota_id'=>$pem2[$i-1],
                                    'tanggal'=>$tanggal,
                                    'jenis_transaksi'=>$test,
                                    'nominal_transaksi'=>$pem1[$i-1],
                                    'id_user'=>$idUser1,
                               ];

                                DB::table('tb_simpanan')->insert($data);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire