Is it possible to have integer column nullabale in laravel?
I have table image where i store multiple image and get id of my posts products website_banner and I need them to be nullable. For example if I upload multiple image for my product not get error of my posts column have not default value!
my migrations:
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');
        });
                You must call nullable(), like so:
$table->integer('banner_id')->nullable()->unsigned();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With