hasMany('comment', 'user_id', 'id'); } //一个用户只有唯一的简介,在User模型中是一对一的关系 function profile() { return $this->hasOne('profile', 'user_id', 'id'); } //三张表在同一级显示:user、profile、comment public function UserData1() { $user = new User(); $data = $user->with(['profile', 'comment',])->find(); return $data; } //三张表分级显示 public function UserData2() { $user = new User(); $data = $user->with([ 'profile' => function ($query) { $query->with([ 'comment' => function ($query) { } ]); } ])->select(); return $data; } }