title: Why this ERROR: General error: 1364 Field 'user_id' doesn't have a default value
body: <p>i have postqs and users table. user_id is foreign key in postqs table . i have a form and after i submit the form all the data saving in database correctly. but it is not directing to index page its showing this ERROR: </p>
  
  <blockquote>
    <p>SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a
    default value (SQL: insert into <code>Postqs</code> (<code>question</code>, <code>description</code>,
    <code>solution</code>, <code>image</code>, <code>tags</code>, <code>updated_at</code>, <code>created_at</code>) values (hh,
    bb, bb, images .bmp.jpg, bb, 2017-09-20 08:14:32, 2017-09-20
    08:14:32))</p>
  </blockquote>
  
  <p>How i can solve it?</p>
  
  <p>store controller function :</p>
  
  <pre><code>public function store(Request $request)
  {
      $this-&gt;validate($request, [
          'question' =&gt; 'required',
          'description' =&gt; 'required',
          'tags' =&gt; 'required',
  
      ]);
  
      $user = auth()-&gt;user();
      $user-&gt;postqs()-&gt;create($request-&gt;all() );
  
      $input = $request-&gt;all();
      $tags = explode(",", $request-&gt;tags);
  
      $postqs = Postqs::create($input);
      $postqs-&gt;tag($tags);
  
      return redirect()-&gt;route('postqs.index')
                      -&gt;with('success','Your question created successfully');
  </code></pre>
  
  <p>index controller function: </p>
  
  <pre><code>   $postqs=Postqs::whereHas('user')-&gt;get();        
      return view('postqs.index',compact('postqs','users'));
  </code></pre>
  
  <p>postqs model:</p>
  
  <pre><code>    protected $fillable = 
      ['question','description','solution','image','tags','user_id'];
  
      public function user(){
      return $this-&gt;belongsTo("App\User"); }
  </code></pre>
  
  <p>User model: </p>
  
  <pre><code>    public function postqs(){
       return $this-&gt;hasMany("App\Postqs");
      }
  </code></pre>