The following should work
$ad->getcodes()->distinct()->count('pid');
More Related Contents:
- Laravel – Eloquent “Has”, “With”, “WhereHas” – What do they mean?
- Migration: Cannot add foreign key constraint
- Laravel Eloquent groupBy() AND also return count of each group
- Eloquent Collection: Counting and Detect Empty
- Eloquent eager load Order by
- Laravel Eloquent vs DB facade: Why use Eloquent and decrease performance? [closed]
- Laravel. Use scope() in models with relation
- Laravel Eloquent “WHERE NOT IN”
- HasManyThrough with one-to-many relationship
- Getting just the latest value on a joined table with Eloquent
- Laravel Migration Change to Make a Column Nullable
- Select Last Row in the Table
- How to get distinct values for non-key column fields in Laravel?
- How to select specific columns in laravel eloquent
- How to access model hasMany Relation with where condition?
- Eloquent push() and save() difference
- Laravel save / update many to many relationship
- First Or Create
- Laravel: Returning the namespaced owner of a polymorphic relation
- How to setup conditional relationship on Eloquent
- Polymorphic Eloquent relationships with namespaces
- Laravel Eloquent – Where In All
- Clone an Eloquent object including all relationships?
- How to do this in Laravel, subquery where in
- Laravel update model with unique validation rule for attribute
- Get the Query Executed in Laravel 3/4
- postgresql COUNT(DISTINCT …) very slow
- Laravel Checking If a Record Exists
- How to delete file from public folder in laravel 5.1
- How to fix error on Foreign key constraint incorrectly formed in migrating a table in Laravel