Laravel's Eloquent whereTime() filtering method
Laravel provides many additional methods other than standard methods. You might be familiar with
whereJsonLength(). And these additional methods are worth checking.
In this article, we will see
whereTime(), one of the supplementary methods that comes in handy when you want to compare the table’s field value with a specific time.
whereTime() method helps to get records matching the specific time.
whereTime('fieldName', 'operator', 'time');
- The first parameter is
fieldNamewith which a comparison is to be done.
- The second parameter is an
operatorfor comparison, such as
- The third parameter is a
timefor comparison in
$users = User::whereTime('login_at', '11:12:31')->get();
$orders = Order::whereTime('created_at', '10:01:19')->get();
Happy 😄 coding
With ❤️ from 🇮🇳