laravel 5 - paginate total() of a query with distinct
问题 I have a query to get photos according to values in a pivot table, that stores the relation of "pics" and "tags": #photos $q = PicTag::select(DB::raw('distinct(pics.id)'), 'pics.url', 'pics.titel', 'pics.hits', 'pics.created_at', 'users.username', 'users.displayname') ->leftJoin('pics', 'pics.id', '=', 'pic_tag.pic_id') ->leftJoin('users','users.id','=','pics.user_id') ->whereIn('pic_tag.tag_id', $tagids); if($cat) $q->where('typ',$cat); if($year) $q->where('jahrprod',$year); $pics = $q-