加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – laravel中的整数可空列

发布时间:2020-12-14 19:35:30 所属栏目:大数据 来源:网络整理
导读:是否可以在laravel中使用整数列nullabale? 我有表格图像,我存储多个图像,并获得我的帖子产品的网站website_banner,我需要它们可以为空.例如,如果我为我的产品上传多个图像而不是我的帖子列的错误没有默认值! 我的迁移: Schema::create('images',function
是否可以在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’) – >可为空() – >无符号();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读