A laravel trait to deal with time and dates with scope for eloquent models.
Install using composer
composer require rukhsar/moments
Simply call Moments
trait in your model using use Rukhsar\Moments\Moments
.
<?php
namespace App;
use Rukhsar\Moments\Moments;
class User extends Model
{
use Moments;
// your remaining model class content
}
Then you can call Moments scopes like below
<?php
$users = User::currentDay()->get();
-
currentMinute
Parameter : none -
lastMinute
Parameter : none -
currentHour
Parameter : none -
lastHour
Parameter : none -
currentDay
Parameter : none -
lastDay
Parameter : none -
currentWeek
Parameter : none -
lastWeek
Parameter : none -
currentMonth
Parameter : none -
currentYear
Parameter : none -
lastYear
Parameter : none -
lastSeconds
Parameter :(int) $countSeconds
-
lastMinutes
Parameter :(int) $countMinutes
-
lastHours
Parameter :(int) $countHours
-
lastDays
Parameter :(int) $countDays
-
lastWeeks
Parameter :(int) $countWeeks
-
lastMonths
Parameter :(int) $countMonths
-
lastYears
Parameter :(int) $countYears