【发布时间】:2019-08-11 07:42:12
【问题描述】:
我在 laravel 的 join eloquent 中使用 from "with",我想在获取查询结果时使用 select,但返回错误,因为例如我使用 with(['user]) 并且 user 是我的模型名称而不是表名称(表的名称是用户) 有什么方法可以在我的模型名称中使用“选择”吗? 或者我使用除了获取除特定列之外的所有默认列?
谢谢
这是我的查询:
AlbumGalleryManagement::with('image','user')
->whereHas('organization', function ($q2) use ($organizationSlug){
$q2->where('organization_slug', $organizationSlug);
})
->join('province_approves','province_approves.approved_id','album_gallery_managements.id')
->where('province_approves.approved_type',self::ALBUMMODEL)
->where('published_at','<=',$nowDate)
->orderBy('published_at','DESC')
->orderBy('album_gallery_managements.id','DESC')
->paginate(self::PAGINATE);
【问题讨论】: