Published 7 months ago by Raywachaga
How do you count the duplicate columns in a database using eloquent model querying?
For example, in SQL, there's this command:
SELECT name, COUNT(email) FROM users GROUP BY email HAVING ( COUNT(email) > 1 )
The code above will return the names from all columns with similar email addresses.
What I'm trying to achieve is to get the count of duplicate entries, i.e.
$noOfjobsFromSameCustomers = App\Workflow::count();
But I need an additional parameter to specify that the cust_id (a column in the workflows table) is duplicated, something like
$noOfjobsFromSameCustomers = App\Workflow::notDistinct()->orderBy('cust_id')->count();