php – 如何在刀片中的Laravel关系函数中传递参数?
作者:互联网
Student.php
它有很多费用
class student extends Model{
public function fees($round){
return $this->hasMany(fee::class)->where('payment_round','=',$round);
}
}
Fee.blade.php
@foreach($student->fees("parameter") as $fee)
{{$fee->myproperty}}
@endforeach
我如何将参数传递给$student->费用(“参数”)?
解决方法:
尝试类似的东西:
@foreach($student->fees($parameter)->get() as $fee)
{{ $fee->myproperty }}
@endforeach
我认为你把相关模型费用的收集与查询构造函数费用混淆了().
标签:php,laravel-5,laravel-5-7,laravel-blade 来源: https://codeday.me/bug/20190705/1387070.html