php – laravel中的整数可空列

前端之家收集整理的这篇文章主要介绍了php – laravel中的整数可空列前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可以在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’) – >可为空() – >无符号();

猜你在找的Laravel相关文章