How to filter out the information with empty records in the joint query in the laravel framework?
黄舟
黄舟 2017-05-16 16:48:45
0
1
343

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?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
世界只因有你

hasMany You can add conditions

Similar to

 public function DisAccountRecord(){
        return $this->hasMany('Dis_Account_Record','Ds_Record_ID','Record_ID')
                ->whereNotNull('updated_at')
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!