Delete Elequent records older than 60 minutes
Solved -> With ceejayoz his link
- Make a date object and minus the amount of time.
- Covert the date object to string to match Eloquent formatting
- Compare formatted string against updated_at
I'm using the following code:
$date = new DateTime;$date->modify('-60 minutes');$formatted = $date->format('Y-m-d H:i:s');MyModel::where('updated_at', '<=', $formatted)->delete();
Thanks ceejayoz!