title: How can I update the value if it's null in Laravel with fill?
body: <p>I have a page with a lot of checkboxes. The default value for these is &quot;null&quot;. However, when I update a checkbox and put it to &quot;true&quot;, I am not able to put it back into null even if I leave the field empty. I would want to do that if the checkbox is in the form but not checked, I still have &quot;key&quot; =&gt; null in my data, in order to fill my model with the empty values.</p>
  <p>Here is my form, request and controller.</p>
  <pre><code>// EXAMPLE OF ONE INPUT
  &lt;input id=&quot;permis_de_conduire_international_1&quot; type=&quot;checkbox&quot; name=&quot;permis_de_conduire_international&quot; value=&quot;1&quot;&gt;
  </code></pre>
  <pre><code>&lt;?php
  
  namespace App\Http\Requests;
  
  use Illuminate\Foundation\Http\FormRequest;
  
  class StorePostRequestRegisterStep4 extends FormRequest
  {
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
          return true;
      }
  
      /**
       * Get the validation rules that apply to the request.
       *
       * @return array
       */
      public function rules()
      {
          return [
              'agent_de_securite' =&gt; 'nullable|boolean',
              'investigation' =&gt; 'nullable|boolean',
              'transport_de_valeur' =&gt; 'nullable|boolean',
              'serrurier' =&gt; 'nullable|boolean',
              'technicien_camera' =&gt; 'nullable|boolean',
              'port_d_arme' =&gt; 'nullable|boolean',
              'arme_a_feu_a_autorisation_restreinte' =&gt; 'nullable|boolean',
              'permis_de_conduire' =&gt; 'nullable|boolean',
              'vehicule_de_randonnee' =&gt; 'nullable|boolean',
              'poids_lourds' =&gt; 'nullable|boolean',
              'vehicule_d_urgence' =&gt; 'nullable|boolean',
              'permis_de_conduire_international' =&gt; 'nullable|boolean',
            'permis_moto' =&gt; 'nullable|boolean',
              'permis_autobus' =&gt; 'nullable|boolean',
              'autre_permis' =&gt; 'nullable|array',
              'autre_permis.*' =&gt; 'required|string'
          ];
      }
  }
  </code></pre>
  <pre><code>    public function update(StorePostRequestRegisterStep4 $request)
      {
          $data = $request-&gt;validated();
          $pro = Pro::find($request-&gt;user()-&gt;id);
          $pro-&gt;fill($data);
          $pro-&gt;save();
  
          return redirect()-&gt;route('register-step4.edit');
      }
  
  </code></pre>
  <p>How can I set to &quot;null&quot; if the box is not checked?</p>