屌大的大神,使用关联模型抛出的对象怎么遍历 分页呢

浏览:280 发布日期:2017/11/24 分类:求助交流
使用关联模型抛出的对象怎么遍历 分页呢?namespace app\api\model;


class Theme extends BaseModel
{
    public function topicImg(){
    return $this->belongsTo('Image','topic_img_id','id');
    }

    public function headImg(){
        return $this->belongsTo('Image','head_img_id','id');
    }

    public function themeProduct(){
        return $this->hasMany('theme_produce','theme_id','id');
    }
}
namespace app\api\controller\v1;

use app\api\model\Theme as ThemeModel;
use app\api\validate\IDCollection;

class Theme
{

    public function getSimpleList($ids=''){

        (new IDCollection())->goCheck();
        $ids =explode(',',$ids);
        $result = ThemeModel::with('topicImg,headImg')->paginate($ids);
        var_dump($result);

    }

}



最佳答案
评论( 相关
后面还有条评论,点击查看>>