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' => true
You 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 theDB
facade.
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
QueryBuilder
iscreated_at
- when using
EloquentBuilder
it gets theCREATED_AT
set on the model, and if it doesn't find one it defaults to thecolumn
value set in the config
BASIC METHODS
yesterday
today
tomorrow
betweenDates
TO DATE
weekToDate
monthToDate
quarterToDate
yearToDate
LAST
lastMinute
lastHour
lastWeek
lastMonth
lastQuarter
lastYear
LAST N
lastMinutes
defaults at 5 minuteslastHours
defaults at 2 hourslastDays
defaults at 7 dayslastWeeks
defaults at 2 weekslastMonths
defaults at 2 monthslastQuarters
defaults at 2 quarterslastYears
defaults at 2 years
THIS
thisWeek
thisMonth
thisQuarter
thisYear
NEXT
nextMinute
nextHour
nextWeek
nextMonth
nextQuarter
nextYear
NEXT N
nextMinutes
defaults at 5 minutesnextHours
defaults at 2 hoursnextDays
defaults at 7 daysnextWeeks
defaults at 2 weeksnextMonths
defaults at 2 monthsnextQuarters
defaults at 2 quartersnextYears
defaults 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