2016-06-12 89 views

回答

0

運行php artisan vendor:publish

嘗試編輯遷移 '創建地址表' 並更改

$table->string('city',60);

$table->integer('city_id')->unsigned(); 
$table->foreign('city_id')->references('id')->on('cities'); 

然後繼續創建的模型即關係後

在城市模型

public function address() 
{ 
    return $this->hasOne('App\Address'); 
} 

,並創建php artisan make:model Address一個新的地址模式,並添加以下內容:

protected $table = "addresses"; 
public function city() 
{ 
    return $this->hasOne('App\City'); 
} 

然後,您可以複製其他的方法,如果你需要他們