title: How to store key with NULL value in JSON database field by laravel?
body: <p>Imagine this :</p>
  
  <pre><code>&lt;input name="bank[account]"&gt;
  &lt;input name="bank[name]"&gt;
  &lt;input name="bank[status]"&gt;
  </code></pre>
  
  <p>All of this fields store in on column in DB as JSON.</p>
  
  <p>I used Laravel <code>$casts</code> to introduce this field as an array:</p>
  
  <pre><code>protected $casts = [
      'bank' =&gt; 'array',
  ]
  </code></pre>
  
  <p>Now the problem is all <code>bank[]</code> filed is <code>nullable</code> and when user didn't fill some of that, nothing stored in DB and when i try to show stored value to users i got <code>Undefined index</code> error.</p>
  
  <p>I need to store <code>Empty</code> or <code>NULL</code> input fields in DB like this <code>"Key":NULL</code>. in this case it should be like this : </p>
  
  <pre><code>{"name":NULL,"account":NULL,"status":NULL}
  </code></pre>
  
  <p>I use <a href="https://laravel.com/" rel="nofollow noreferrer">Laravel 5.7</a> and <a href="https://laravel.com/docs/5.7/validation#form-request-validation" rel="nofollow noreferrer">Form Request Validation</a> to process my forms.</p>