Reputation: 788
I cant seem to work out why I am getting this error on this migration file?
Error
[37;41m [Symfony\Component\Debug\Exception\FatalThrowableError] ←[39;49m ←[37;41m Call to a member function nullable() on null ←[39;49m
The date on the file is after the foreign id creation in the Customers table.This is laravel 5.3. How can I resolve this error?
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');
});
}
Upvotes: 9
Views: 10667
Reputation: 1
You replace it like this - remove the s
from timestamp:
$table->timestamp('date_from');
$table->timestamps('date_day');
Upvotes: 0
Reputation: 1049
Remove these two lines from your code
$table->timestamp('date_from')->nullable();
$table->timestamp('date_to')->nullable();
And only include this line for the timpstamping:
$table->timestamps();
Upvotes: 0
Reputation: 867
Use timestamp
method in this two lines...
$table->timestamp('date_from')->nullable();
$table->timestamp('date_to')->nullable();
timestamps()
not accepts any argument and creates two colums : created_at
and updated_at
See Here
Upvotes: 18