2017-01-07 5 views
3

この移行ファイルでこのエラーが発生する理由がわかりません。Laravel Migration Error

エラー

[37; 41メートル[symfonyの\コンポーネント\デバッグ\例外\ FatalThrowableError]←[39; 49メートル ←[37;メンバ関数NULL可能に41メートル()の呼び出しはnullで←[39 ; 49m

ファイルの日付は、Customersテーブルの外部IDの作成後です。これはlaravel 5.3です。このエラーを解決するにはどうすればよいですか?この2行

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');      
    }); 
} 

答えて

3

使用timestamp方法...

$table->timestamp('date_from')->nullable(); 
$table->timestamp('date_to')->nullable(); 

timestamps()は、任意の引数を受け入れ、2つのcolumsを作成していない:created_atupdated_atHere

4

を参照してください、あなたからの2行を削除しますコード

$table->timestamp('date_from')->nullable(); 
$table->timestamp('date_to')->nullable(); 

timpstampingには次の行のみを含めます。

$table->timestamps();