Skip to content
Advertisement

Laravel Eloquent – Specific Date Filtering

I have a Laravel app that sends reminders on specific days prior to a tenancy_start_date. Essentially every 3 days, then 2 days, then daily ([30, 27, 24, 21, 19, 17, 15, 13, 11, 9, 8, 7, 6, 5]) Is there a neater way to code this:

JavaScript

Advertisement

Answer

What is your database? You can use specific date difference functionality. For example in MySQL, you can try this:

JavaScript

In PostgreSQL you also use DATEDIFF but you have to specify day as parameter. In other database engines you can research for similar solution

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement