lundi 27 avril 2020

Store array inside of array in db using laravel

I have a common array from request named complemntartData[]. from that array i get some values.i need to store these data in db table field.i used implode function but it shows array to string conversion. this is complementaryData


    if($request->input('complementaryData')){
       foreach($request->input('complementaryData') as $name => $value){
          $data = explode ("_", $name);
          $A = [];
          $B = [];
          if($data[0]=="TextField"){
            $B["id"] = $data[1];
            $A["TextField"] = &$B;
            $B["data"] = $value;
           }
           if($data[0]=="Archive"){
              $B["id"] = $data[1];
              $A["Archive"] = &$B;
              $B["data"] = $value;
           }
           if($data[0]=="MultipleChoice"){
              $B["id"] = $data[1];
              $A["MultipleChoice"] = &$B;
              $B["sub"] = $value;
           }
           $eventParticipants->complementaryData = implode(',',$A);
           //dd($eventParticipants->complementaryData);
        }
   }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire