use SoftDeletes;//使用软删除
/**
* 隐藏字段(必有得参数不然返回值永远多一个hasOnetable)
* @var array
*/
public $hidden = ['hasOnetable','hasTwotable'];
public function hasOnetable(){
return $this->hasOne('App\hasOnetable','id','one_id');//第一个是关联表主键,第二个是本表的外键
}
public function hasTwotable(){
return $this->hasOne('App\hasTwotable','two_table_id','id');
}
本文为王思彤原创文章,转载无需和我联系,但请注明来自王思彤博客wangsitong.com