title: Laravel : foreign key -> doesn't have a default value
body: <p><br>
  Hi ! I read other questions but I don't find my answer.<br>
  I want to create data but give me this error:</p>
  
  <blockquote>
    <p>SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a
    default value</p>
  </blockquote>
  
  <p>Controller:<br></p>
  
  <pre><code>public function store(BannerRequest $request)
      {
          Banner::create($request-&gt;all());
  
          flash()-&gt;success('Success', 'Your banner has been created.');
  
          return back(); // temporary
      }
  </code></pre>
  
  <p>and my Table:<br></p>
  
  <pre><code>Schema::create('banners', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;integer('user_id')-&gt;unsigned();
              $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')-&gt;onDelete('cascade')-&gt;onUpdate('cascade');
              $table-&gt;string('street', 40);
              $table-&gt;string('city', 40);
              $table-&gt;string('zip', 15);
              $table-&gt;string('country', 40);
              $table-&gt;string('state', 40);
              $table-&gt;integer('price');
              $table-&gt;text('description');
              $table-&gt;timestamps();
          });
  </code></pre>
  
  <p>and this is my model  :<br></p>
  
  <pre><code> namespace App;
      use Illuminate\Database\Eloquent\Model;
      use App\Banner;
      use Symfony\Component\HttpFoundation\File\UploadedFile;
  
      class Photo extends Model
      {
          protected $table = 'banners_photos';
          protected $fillable = ['name', 'path', 'Thumbnail_path'];
          protected $file;
  
          public function banners()
          {
              return $this-&gt;belongsTo(Banner::class);
          }
          public static function formFile(UploadedFile $file)
          {
              $photo = new static;
              $photo-&gt;file = $file;
              $photo-&gt;fill([
                  'name'           =&gt; $photo-&gt;fileName(),
                  'path'           =&gt; $photo-&gt;filePath(),
                  'Thumbnail_path' =&gt; $photo-&gt;ThumbnailPath()
              ]);
              return $photo;
          }
          public function fileName()
          {
              $name = sha1(time() . $this-&gt;file-&gt;getClientOriginalName());
              $extension = $this-&gt;file-&gt;getClientOriginalExtension();
              return "{$name}.{$extension}";
          }
          public function filePath()
          {
              return $this-&gt;baseDir() . DIRECTORY_SEPARATOR . $this-&gt;fileName();
          }
          public function ThumbnailPath()
          {
              return $this-&gt;baseDir() . '/tn-' . $this-&gt;fileName();
          }
          public function baseDir()
          {
              return 'images/photos';
          }
          public function upload()
          {
              $this-&gt;file-&gt;move($this-&gt;baseDir(), $this-&gt;fileName());
              $this-&gt;makeThumbnail();
  
              return $this;
          }
          public function makeThumbnail()
          {
              Image::make($this-&gt;filePath())-&gt;fit(200)-&gt;save($this-&gt;ThumbnailPath());
              return $this;
          }
      }
  </code></pre>
  
  <p>This code worked already and after refactoring become difficult.<br>
  Thank for your helps.</p>