title: Save checkbox values into database
body: <p>I am designing a form where the user can fill up their particulars and submit it to the database. For the most part, it works. There is one part with the form about the driving license class, it does not work. A person can have multiple driving licenses so I made that into a checkbox field. However, when the user selects two or more driving licenses, only the lastly selected driving license appears in the database. So, if a person selects Class1 firstly and then selects Class2, only Class2 appears in the database.</p>
  
  <p>How can I include all the driving licenses selected by the user into one database column?
  I have attached the code below.</p>
  
  <p><strong>form.blade.php</strong></p>
  
  <pre><code>@extends('layout.basiclayout')
  @section('content')
  
  &lt;p&gt;page 1/7&lt;/p&gt;
          {!! Form::open(['url' =&gt; 'form/submit']) !!}
  
               &lt;h3 style= 'text-decoration: underline'&gt;PERSONAL PARTICULARS - &lt;/h3&gt;
               &lt;div class="form-group"&gt;
                    {{Form::label('Name/NRIC', 'Name AS PER NRIC/PASSPORT: ')}}
                    {{Form::text('Name/NRIC', '', ['class' =&gt; 'form-control', 'placeholder' =&gt; 'eg: John Smith'])}}
              &lt;/div&gt;
  
              {{-- start of Driver`s License --}}
              &lt;p&gt;
              &lt;div class="editfield"&gt;
                &lt;div class="radio"&gt;
                  &lt;span&gt;&lt;b&gt;Do you have a Driver`s license?&lt;/b&gt;&lt;/span&gt;
                  &lt;div id="Driver_licenseID"&gt;
                     &lt;label&gt;&lt;input type="radio" name="Driver_license" id="yesid" value="Yes" onclick="document.getElementById('Driver_license').style.display='block'"&gt;Yes&lt;/label&gt;
                    &lt;label&gt;&lt;input type="radio" name="Driver_license" id="noid" value="No" onclick="document.getElementById('Driver_license').style.display='none'"&gt;No&lt;/label&gt;&lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="editfield" id="Driver_license" style="display:none"&gt;
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class1" value="Class1"&gt;Class 1 
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class2" value="Class2"&gt;Class 2 
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class2A" value="Class2A"&gt;Class 2A 
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class2B" value="Class2B"&gt;Class 2B &lt;br&gt;
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class3" value="Class3"&gt;Class 3 
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class3A" value="Class3A"&gt;Class 3A 
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class3C" value="Class3C"&gt;Class 3C 
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class3CA" value="Class3CA"&gt;Class 3CA &lt;br&gt;
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class4" value="Class4"&gt;Class 4 
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class4A" value="Class4A"&gt;Class 4A
                &lt;input type="checkbox" name="Driver_license_class" id="Driver_license_class5" value="Class5"&gt;Class 5 
              &lt;/div&gt;
              &lt;/p&gt;
              {{-- End of Driver`s License --}}
  
              &lt;div class="form-group"&gt;
                    {{Form::submit('Next Page', ['class' =&gt; 'btn btn-primary'])}}
              &lt;/div&gt;
  
  {!! Form::close() !!}
  
  @endsection
  </code></pre>
  
  <p><strong>migration file</strong></p>
  
  <pre><code>&lt;?php
  use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreatePersonalInfosTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('personal_infos', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;String('Name');
              $table-&gt;String('Driver_license');
              $table-&gt;String('Driver_license_class');
              $table-&gt;timestamps();
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('personal_infos');
      }
  }
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>&lt;?php
  namespace App\Http\Controllers;
  use Illuminate\Http\Request;
  use App\PersonalInfo;
  
  class PersonalInfoController extends Controller
  {
            public function submit(Request $request){
          $this-&gt;validate($request,[
              'Name/NRIC' =&gt; 'required',
          ]);
  
          $PersonalParticulars = new PersonalInfo;
          $PersonalParticulars-&gt;Name = $request-&gt;input('Name/NRIC');
          $PersonalParticulars-&gt;Driver_license = $request-&gt;input('Driver_license');
          $PersonalParticulars-&gt;Driver_license_class = $request-&gt;input('Driver_license_class');
  
          $PersonalParticulars-&gt;save();
      return redirect('http://formapplication.dev/page2');
      }
  }
  </code></pre>