用到了yii2 hasMany() 方法,一对多关联

view页面代码;其中supply,item,price是一个AR类都是一个类,item和prices是一对多关系;

            [
                'label' => '参考',
                'format' => 'html',
                'value' => function ($model){

                    $str='';
                    foreach($model->item->price as $value){
                        $str=$str.$value->supply->name.'-'.$value->price_buy.', ';
                    }
                    return $str;
                }
            ],

item AR类关键代码

 

posted @ 2017-04-12 18:42  jerryhe326  阅读(2074)  评论(0编辑  收藏  举报