gpt4 book ai didi

laravel-5.3 - Laravel迁移错误

转载 作者:行者123 更新时间:2023-12-04 18:02:44 24 4
gpt4 key购买 nike

我似乎无法弄清楚为什么我在此迁移文件上收到此错误?

错误

[37;41m [Symfony\Component\Debug\Exception\FatalThrowableError] ←[39;49m ←[37;41m Call to a member function nullable() on null ←[39;49m



文件上的日期是在Customer表中创建外部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_atupdated_at参见 Here

关于laravel-5.3 - Laravel迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41522569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com