EMfinanga
3 months ago
355
3
Laravel

Insert Multiple id to another table

Posted 3 months ago by EMfinanga

I have the ajax, which pass the id like this 1,2,3

but when i create it, it save all id in one row, so what can i do to insert those list id

my controller

public function addMultipleUnit(Request $request){

        $ids = $request->ids;
       // $idsList=explode(",",$ids);
      // dd($ids);
 
  
            foreach ($ids as  $key=> $value) {
            IssuedUpload::create([
                'unit_id' => $ids[$key],
            
                ]);


               }   

           return response()->json(['status'=>true,'message'=>"added successfully."]);   

          // }
         }

Please sign in or create an account to participate in this conversation.