1

I created table migrations in Laravel using php artisan migrate:make. When I tried to create the tables in the database, I got an error:

[ErrorException] 
Creating default object from empty value

What is this related to? No tables are created nor can I find any errors in my migrations.

I have 25 tables in the migrations folder, all look similar to this.

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAddressesTable extends Migration {
    public function up() {
        Schema::create("addresses", function() {
            $table->engine = "InnoDB";

            $table->increments("id");
            $table->integer("user_id")->unsigned();

            $table->string("street");
            $table->string("city");
            $table->integer("postal_code")->unsigned();

            $table->foreign("user_id")->references("id")->on("users");

            $table->softDeletes();
            $table->timestamps();
        });
    }

    public function down() {
        Schema::dropIfExists("addresses");
    }
}

1 Answer 1

3

Well you miss $table that you pass to the function.

Your schema create function needs to be in this style...

Schema::create('addresses', function(Blueprint $table)

Sign up to request clarification or add additional context in comments.

1 Comment

Nice catch. I just happened to copy and paste the only faulty file here. It was the only one of the 25 files that had that missing. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.