2016-06-12 44 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'); 
} 

然后,您可以复制其他的方法,如果你需要他们