Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MuhammadMaaz's avatar

@michaloravec

well i made few changes and it worked,now i'm facing a problem,actually i have faced it before too but rn i'm not able to solve it,please guide me about it.

 Illuminate \ Database \ QueryException (HY000)
SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL: insert into `products_images` (`image`, `product_id`, `updated_at`, `created_at`) values (3762.jpg, 1, 2020-06-03 04:48:58, 2020-06-03 04:48:58))
guybrush_threepwood's avatar

Hi @muhammadmaaz

You need to set the primary key to autoincrement on your create_product_images_table migration.

This is the default way if you're using Laravel 7:

    public function up()
    {
        Schema::create('products_images', function (Blueprint $table) {
            $table->id();
            // Rest of your fields
        });
    }

If in doubt, paste here your migration file and we'll take a look.

MuhammadMaaz's avatar

@michaloravec i don't know much about it,i just debugged it again from the start,btw i face an issue that some times by restarting my pc,code works well,i don't know when i need to restart my pc.

Previous

Please or to participate in this conversation.