Laravel 迁移错误
Laravel Migration Error
我似乎无法弄清楚为什么我会在这个迁移文件上收到这个错误?
错误
[37;41m [Symfony\Component\Debug\Exception\FatalThrowableError] ←[39;49m
←[37;41m Call to a member function nullable() on null ←[39;49m
文件上的日期是在客户 table.This 中创建外国 ID 之后 laravel 5.3。我该如何解决这个错误?
public function up()
{
Schema::create('invoices', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('customer_id')->unsigned();
$table->timestamps('date_from')->nullable();
$table->timestamps('date_to')->nullable();
$table->date('invoice_date')->nullable();
$table->date('due_at')->nullable();
$table->integer('total_charge')->nullable();
$table->integer('rate')->nullable();
$table->integer('total_hours')->nullable();
$table->string('status')->nullable();
$table->string('description', 255)->nullable();
$table->string('notes', 255)->nullable();
$table->string('invoice_ref')->nullable();
$table->foreign('customer_id')
->references('id')->on('customers')
->onDelete('cascade');
});
}
在这两行中使用timestamp
方法...
$table->timestamp('date_from')->nullable();
$table->timestamp('date_to')->nullable();
timestamps()
不接受任何参数并创建两个列:created_at
和 updated_at
参见 Here
从您的代码中删除这两行
$table->timestamp('date_from')->nullable();
$table->timestamp('date_to')->nullable();
并且只包括这一行用于 timpstamping:
$table->timestamps();
你这样替换它 - 从时间戳中删除 s
:
$table->timestamp('date_from');
$table->timestamps('date_day');
我似乎无法弄清楚为什么我会在这个迁移文件上收到这个错误?
错误
[37;41m [Symfony\Component\Debug\Exception\FatalThrowableError] ←[39;49m ←[37;41m Call to a member function nullable() on null ←[39;49m
文件上的日期是在客户 table.This 中创建外国 ID 之后 laravel 5.3。我该如何解决这个错误?
public function up()
{
Schema::create('invoices', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('customer_id')->unsigned();
$table->timestamps('date_from')->nullable();
$table->timestamps('date_to')->nullable();
$table->date('invoice_date')->nullable();
$table->date('due_at')->nullable();
$table->integer('total_charge')->nullable();
$table->integer('rate')->nullable();
$table->integer('total_hours')->nullable();
$table->string('status')->nullable();
$table->string('description', 255)->nullable();
$table->string('notes', 255)->nullable();
$table->string('invoice_ref')->nullable();
$table->foreign('customer_id')
->references('id')->on('customers')
->onDelete('cascade');
});
}
在这两行中使用timestamp
方法...
$table->timestamp('date_from')->nullable();
$table->timestamp('date_to')->nullable();
timestamps()
不接受任何参数并创建两个列:created_at
和 updated_at
参见 Here
从您的代码中删除这两行
$table->timestamp('date_from')->nullable();
$table->timestamp('date_to')->nullable();
并且只包括这一行用于 timpstamping:
$table->timestamps();
你这样替换它 - 从时间戳中删除 s
:
$table->timestamp('date_from');
$table->timestamps('date_day');