'array', 'labels' => 'array', ); /** * 字段筛选 * @param \Illuminate\Database\Eloquent\Builder $builder * @param $field * @return \Illuminate\Database\Eloquent\Builder */ public function scopeOfField($builder, $field) { switch ($field) { // 图片 case "avatar": $builder->where('field', 'headimgurl'); break; case "photo": $builder->whereIn('field', ['photo_src', 'photo_1', 'photo_2', 'photo_3', 'photo_4']); break; // 文字 case "nickname": $builder->where('field', 'nickname'); break; case "question": $builder->where('field', 'question'); break; case "invite_answer": $builder->where('field', 'invite_answer'); break; case "introduce": $builder->where('field', 'introduce'); break; // 语音 case "voice": $builder->where('field', 'voice'); break; case "invite_voice": $builder->where('field', 'invite_voice'); break; case "invite_sing": $builder->where('field', 'invite_sing'); break; } return $builder; } }