student 表 外键 grade_id
grade 表主键 id
在 模型中student
表关联方法
public function Grade(){
return $this->hasOne('Grade','id','grade_id','');
}

在控制器中 使用
$artres = Student::with("grade")->paginate()->toArray();

with 表示关联, toArray 必须用负责转换不成数组

相关文章:

  • 2021-07-12
  • 2022-12-23
  • 2021-09-24
  • 2022-12-23
  • 2021-05-20
  • 2021-09-23
  • 2022-01-17
  • 2021-09-08
猜你喜欢
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2021-08-09
  • 2021-06-17
相关资源
相似解决方案