是否可以在laravel中使用整数列nullabale?
我有表格图像,我存储多个图像,并获得我的帖子产品的网站website_banner,我需要它们可以为空.例如,如果我为我的产品上传多个图像而不是我的帖子列的错误没有默认值!
我的迁移:
Schema::create('images',function (Blueprint $table) { $table->increments('id'); $table->string('image'); $table->integer('post_id')->unsigned(); $table->integer('product_id')->unsigned(); $table->integer('banner_id')->unsigned(); $table->timestamps(); }); Schema::table('images',function($table) { $table->foreign('post_id')->references('id')->on('posts'); $table->foreign('product_id')->references('id')->on('products'); $table->foreign('banner_id')->references('id')->on('banners'); });
解决方法
$表 – >整数( ‘banner_id’) – >可为空() – >无符号();