title: MySQL/Laravel handling null values when saving model
body: <p>When saving my form, it saves properly and all, but if a value in the form was blank, it will fail to save, even if the column was set to allow null.</p>
  
  <p>As a result, the only way to get it to work seems to be checking if the value exists, otherwise set it to null manually (seen below).  </p>
  
  <pre><code>$model = \Blah\Model::where(blahblah)-&gt;first;
  $model-&gt;value = $value ? $value : null;
  $model-&gt;save();
  </code></pre>
  
  <p>I have issues doing this though too just because if a value was 0 (zero), it would set it to null because of the way php interprets conditionals.</p>
  
  <p>I don't want to have to do this for every value in every model.  So is there a way to make it properly handle null values so that if the field was blank it will save null into the model at that column instead of giving me an error?</p>
  
  <p>So basically is there a way to properly handle null values in SQL/eloquent that will keep 0 value, and if it's blank, properly save null value?</p>
  
  <p>Edit:  The generated query</p>
  
  <pre><code>General error: 1366 Incorrect integer value: '' for column 'Strength' at row 1 (SQL: update `playerstats` set `Strength` = where `id` = 1)
  </code></pre>