title: Update multiple data using same variable name input from a form into single column in database in Laravel
body: <p>hye everyone. </p>
  
  <p>Im newbies in laravel here.<br></p>
  
  <p>From my form, both variable name : <code>sequenceJawatankuasa</code> and <code>seniorityJawatankuasa</code> supposed to pass array value to controller. This is because, I want to update many different input data for both fields which is <code>Sequence</code> and <code>Seniority</code> using different <strong>ID</strong> after clicked button <code>Simpan Turutan</code> <br/> <br/>Then it will pass parameter consists of <strong>ID</strong>, <strong>SequenceJawatankuasa</strong> value, and <strong>seniorityJawatankuasa</strong> value to class yet its model.<br/> But there's stil error and not update the value.Please anyone help me.</p>
  
  <p>here is my Form:</p>
  
  <pre><code>&lt;?php $count = 1; ?&gt;
      @foreach ($jawatankuasa as $jawatankuasaListView)   
      &lt;tr height="20" valign="top"&gt;
          &lt;td class="TableCol1Center"&gt;{{ $jawatankuasaListView['ID'] }}&lt;/td&gt;
          &lt;td class="TableCol2Left"&gt;&lt;a href="{{URL::to('pentadbiranjawatankuasadetails/sujk?t=2&amp;jawatankuasaid='.$jawatankuasaListView['ID'].'&amp;bc=1')}}" class="BlueLink"&gt;{{ $jawatankuasaListView['NAMA_JAWATANKUASA'] }}&lt;/a&gt;&lt;/td&gt;
          &lt;td class="TableCol2Left"&gt; {{ $jawatankuasaListView['PENERANGAN'] }}&lt;/td&gt;
          &lt;td class="TableCol2Center"&gt;
              &lt;input type="text" name="seniorityJawatankuasa[]" style="text-align: center;" maxlength="2" size="1" value="{{ $jawatankuasaListView['SENIORITY'] }}" onchange="javascript:FilterChar4(this)"&gt;
          &lt;/td&gt;
          &lt;td class="TableCol2Center"&gt;
              &lt;input type="text" name="sequenceJawatankuasa[]" style="text-align: center;" maxlength="2" size="1" value="{{ $jawatankuasaListView['SEQUENCE'] }}" onchange="javascript:FilterChar4(this)"&gt;
          &lt;/td&gt;
          &lt;td class="TableCol2Center"&gt;
              {{ strcmp( $jawatankuasaListView['SOFT_DELETE'], SOFT_DELETE ) == 0 ? '&lt;b&gt;&lt;font color="red"&gt;Tidak Aktif&lt;/font&gt;&lt;/b&gt;' : '&lt;b&gt;Aktif&lt;/b&gt;' }}&lt;/td&gt;                            
          &lt;/td&gt;                           
          &lt;td class="TableCol3Center"&gt;
              @if( strcmp( $jawatankuasaListView['SOFT_DELETE'], SOFT_DELETE ) != 0 )
                  &lt;input type="checkbox" name="DelPstId[]" value="{{ $jawatankuasaListView['ID'] }}"&gt;
              @endif
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;?php $count++; ?&gt;
  @endforeach
      &lt;tr height="20"&gt;
          &lt;td align="right"&gt;
              &lt;input type="button" name="btnSave" value="Simpan Turutan" class="NormalTextCenter" onclick="SimpanTurutan();" &gt;
          &lt;/td&gt;
      &lt;/tr&gt; &lt;br/&gt;
  </code></pre>
  
  <p>Javascript : <br/></p>
  
  <pre><code>function FilterChar4(field) {
      var vResult = new String();
      var vNum = "0123456789.";
      var vChar = field.value.split(""); // create array
      for (i=0; i&lt;vChar.length; i++) {
         if (vNum.indexOf(vChar[i]) != -1) vResult += vChar[i];
      }
      if (field.value != vResult) field.value = vResult; 
  }
  function SimpanTurutan(){
      if (confirm("Simpan turutan ini?")) {       
          ShowLoading("Loading");
          var url = "{{ URL::to('pentadbiranjawatankuasaupdateturutan/sujk?t=2') }}" ;
          document.JawatankuasaListForm.action = url;
          document.JawatankuasaListForm.submit();
          return true;
      }
  }
  </code></pre>
  
  <p><br/>
  Controller: <br/></p>
  
  <pre><code>public function pentadbiranJawatankuasaUpdateTurutan()
  {           
      $kodJawatankuasaClass = new KodJawatankuasaClass();
      try{
  
          $input = Input::all();  
  
          #update process
          if(( isset( $input['jawatankuasaid'])) &amp;&amp; ( isset( $input['seniorityJawatankuasa'])) &amp;&amp; ( isset( $input['sequenceJawatankuasa'])) ){
              $updateTurutan = $kodJawatankuasaClass-&gt;getJawatankuasaUpdateTurutanByID( $input['jawatankuasaid'], $input['seniorityJawatankuasa'], $input['sequenceJawatankuasa'] );
          }
  
          #declaration pagination
          $pagination = new PaginationBase();
  
          #get page no
          $pageNo = empty( $_GET['pageNo'] ) ? 0 : $_GET['pageNo'];
          $pagination-&gt;setPageSize();
  
          #count and get data
          $jawatankuasa_count = $kodJawatankuasaClass-&gt;getJawatankuasaKodPagination($pagination-&gt;getPageSize(), $pageNo, true ); 
          $jawatankuasa= $kodJawatankuasaClass-&gt;getJawatankuasaKodPagination( $pagination-&gt;getPageSize(), $pageNo );
  
          #pagination setting
          $pagination-&gt;setPageDataSize( $jawatankuasa_count );
          $pagination-&gt;setCurrentPage( $pageNo );
  
          return View::make('sujk/pentadbiran/jawatankuasa/jawatankuasa-view-sujk', array( 'jawatankuasa' =&gt; $jawatankuasa, 'pagination' =&gt; $pagination ));
      }
      catch (Exception $e) {
          loginfo(ERROR_LOG, $e);
      }
  } 
  &lt;br/&gt; &lt;/br&gt;
  </code></pre>
  
  <p>Class: <br/></p>
  
  <pre><code>public function getJawatankuasaUpdateTurutanByID($id, $seniority, $sequence){ 
          $kodJawatankuasa = new KodJawatankuasa();
          try{
              $kodJawatankuasa-&gt;getJawatankuasaUpdateTurutanByID($id, $seniority, $sequence);     
          }catch(Exception $exception){
              loginfo(ERROR_LOG, $exception);
          }
          return false;
      }
  </code></pre>
  
  <p><br/></p>
  
  <p>Model: <br/></p>
  
  <pre><code>public function getJawatankuasaUpdateTurutanByID( $id, $seniority, $sequence )
  {
      try{
          $this-&gt;whereIn('ID', $id)
               -&gt;update(['SENIORITY' =&gt; $seniority['seniorityJawatankuasa'], 'SEQUENCE' =&gt; $sequence['sequenceJawatankuasa']]); 
  
      }catch(ModelNotFoundException $exception){
          loginfo( ERROR_LOG, $exception );
      }
  }
  </code></pre>