how to use distinct keyword in laravel controller query syntax but count not working code example Example: eloquent get distinct $ad->getcodes()->distinct('pid')->count('pid');