【发布时间】:2021-01-14 05:17:18
【问题描述】:
我有两个模型 Student 和 Fees 有关系
- 学生有很多费用
- 费用属于学生
在Student.php
public function fees()
{
return $this->hasMany(Fees::class, 'std_id');
}
在Fees.php
public function student(){
return $this->belongsTo(Student::class,'std_id');
}
现在我需要为个别学生查找费用。我现在该怎么办?
在控制器中
$fees = Fees::with('student')->where('fees->student->id', '=', $request->id)->get();
它不工作......
【问题讨论】: