extract distinct values in eloquent query to an array code example Example: eloquent get distinct $ad->getcodes()->distinct('pid')->count('pid');