0

I have database table, having business_name and user_id with created_at and updated_at, now i want to query data where i will get only thoes user_ids with only business having created_at greater than specific date.

Business::where('created_at', '>' , new \DateTime('2020-08-30'))->distinct('user_id')->get();

now this query return records with created_at greate than this date, but i want user_id who have created business only after this and have no other record before this date.

  • Does this answer your question? [Laravel eloquent where date is equal or greater than DateTime](https://stackoverflow.com/questions/44266337/laravel-eloquent-where-date-is-equal-or-greater-than-datetime) – Refilon Oct 23 '20 at 08:44

1 Answers1

0
Business::whereRaw('MIN(created_at) > ' . new \DateTime('2020-08-30'))->distinct('user_id')->get();
Valen Tin
  • 169
  • 1
  • 12