eloquent select distinct values from model code example Example: eloquent get distinct $ad->getcodes()->distinct('pid')->count('pid');