Download the PHP package frameck/laravel-query-date-helpers without Composer
On this page you can find all versions of the php package frameck/laravel-query-date-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download frameck/laravel-query-date-helpers
More information about frameck/laravel-query-date-helpers
Files in frameck/laravel-query-date-helpers
Package laravel-query-date-helpers
Short Description This is my package laravel-query-date-helpers
License MIT
Homepage https://github.com/frameck/laravel-query-date-helpers
Informations about the package laravel-query-date-helpers
Laravel Query Date Helpers
This package provides some useful query and eloquent builder macros regarding dates.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
-
Using
'register_macros' => false - Using
'register_macros' => trueYou don't you need any additional configuration since the macro are registered directly on the Eloquent and Query builder. If you choose this option you can use all the functions listed below either querying from the model class or from theDBfacade.
All the examples in this section assume that the date is May 8, 2023.
Every method has a column parameter as its second to last, so you can use it in two ways:
Order::weekToDate(now()->subYear(), 'date')passing all parametersOrder::weekToDate(column: 'date')with named parameter
Column default:
- when using
QueryBuilderiscreated_at - when using
EloquentBuilderit gets theCREATED_ATset on the model, and if it doesn't find one it defaults to thecolumnvalue set in the config
BASIC METHODS
yesterdaytodaytomorrowbetweenDates
TO DATE
weekToDatemonthToDatequarterToDateyearToDate
LAST
lastMinutelastHourlastWeeklastMonthlastQuarterlastYear
LAST N
lastMinutesdefaults at 5 minuteslastHoursdefaults at 2 hourslastDaysdefaults at 7 dayslastWeeksdefaults at 2 weekslastMonthsdefaults at 2 monthslastQuartersdefaults at 2 quarterslastYearsdefaults at 2 years
THIS
thisWeekthisMonththisQuarterthisYear
NEXT
nextMinutenextHournextWeeknextMonthnextQuarternextYear
NEXT N
nextMinutesdefaults at 5 minutesnextHoursdefaults at 2 hoursnextDaysdefaults at 7 daysnextWeeksdefaults at 2 weeksnextMonthsdefaults at 2 monthsnextQuartersdefaults at 2 quartersnextYearsdefaults at 2 years
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Frameck
- All Contributors
- This tweet from Caleb Porzio
- Laravel Date Scopes package
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-query-date-helpers with dependencies
spatie/laravel-package-tools Version ^1.14.0
illuminate/contracts Version ^10.0