I'm not sure I understand what you're asking, but maybe this will work for you.
public function scopeUpcoming($query)
{
return $query->whereDate('start_date_time', '>', now());
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi I can't figure out how to write this scope query using Eloquent in Laravel. This is my latest attempt:
public function scopeUpcoming($query)
{
return $query->where('start_date_time', '>', date('Y-m-d H:i:s'));
}
I have a table called 'Lessons' where the start_date_time is stored as the local timezone. Since Mysql doesn't allow the timezone to be stored in the same date_time column, I have another column in the table calledtime_zone where the relevant time zone is stored.
My goal is to compare start_date_time with the current datetime in the timezone of the lesson... , but currently the query is comparing start_date_time with the current datetime in UTC.
Is there anyway to achieve this without having to store start_date_time in UTC? Thanks for any tips.
Please or to participate in this conversation.