0

I want to pick the dates from the 'reservation_date' column if the same column repeats itself X number of times(I'd be using a variable to compare). Something like

$arrayOfDates => Reservations::groupBy('reservation_date')->

Now I can't find anywhere on how to select based on the count of the repetition of a value. Something like

where(count(as count of the items in a group >= $X)->get()
  • This won't be an eloquent solution but this will help you `\DB::table('topics as lt')->selectRaw('DISTINCT topic,id')->whereRaw('(SELECT COUNT(topic) from laravel.topics as repetetion where `topic`= lt.topic group by topic) > 3')` just replace the columns and table names a per your code. – harish durga Feb 05 '22 at 13:47
  • Does this answer your question? [Laravel "group by having" query issues](https://stackoverflow.com/questions/26747740/laravel-group-by-having-query-issues) – Paul T. Feb 05 '22 at 13:47
  • You've [already asked a similar question](https://stackoverflow.com/questions/70992309/how-to-group-items-in-laravel-and-echo-the-value-if-group-count-is-larger-than-a), so why another one? – Paul T. Feb 05 '22 at 13:53

0 Answers0