title: How to use nullable in foregin in Laravel?
body: <p>I create migration in laravel 5.6.</p>
  
  <p>I need add user information if the user was logged in my website else add <code>0</code> in column.</p>
  
  <p>My code is:</p>
  
  <pre><code>$table-&gt;integer('user_id')-&gt;default(0);
  $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');
  </code></pre>
  
  <p>But aftre run <code>migrate</code> show this error:</p>
  
  <pre><code>SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint  
  </code></pre>
  
  <p>I need add default <code>0</code> or <code>null</code> in column or add <code>user_id</code> in column if the user was logged in my website.</p>
  
  <p>How to issue this problem?</p>