select distinct without collection laravel query code example Example: eloquent get distinct $ad->getcodes()->distinct('pid')->count('pid');