Relationship definition function in model file Dis_Reocrd.php
//1对多关系
public function DisAccountRecord(){
return $this->hasMany('Dis_Account_Record','Ds_Record_ID','Record_ID');
}
Use the following statement to call
$builder = Dis_Record::where('Users_ID', $Users_ID)
->with('DisAccountRecord')
At this time, we need to filter out the empty result set of DisAccountRecord(). How should we do this?
世界只因有你2017-05-16 16:50:45
hasMany
You can add conditions
Similar to
public function DisAccountRecord(){
return $this->hasMany('Dis_Account_Record','Ds_Record_ID','Record_ID')
->whereNotNull('updated_at')
}