Download the PHP package laracraft-tech/laravel-date-scopes without Composer

On this page you can find all versions of the php package laracraft-tech/laravel-date-scopes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-date-scopes

Laravel Date Scopes

Latest Version on Packagist Tests License Total Downloads Imports

This package provides a big range of useful date scopes for your Laravel Eloquent models!

Let's assume you have a Transaction model. If you now give it the DateScopes trait, you can do something like this:

ToC

Installation

You can install the package via composer:

Configuration

Inclusive/Exclusive

In statistics, when asking for "the last 7 days", the current day may or may not be included in the calculation depending on the context and the specific requirements of the analysis.

If you want to include the current day in the calculation, you would generally use an inclusive range, meaning that you would include records created on the current day as well as records created in the previous 6 days.

If you want to exclude the current day in the calculation, you would generally use an exclusive range, meaning that you would include records created in the previous 7 days, but not records created on the current day.

Ultimately, it depends on the context and what you're trying to achieve with your data. It's always a good idea to clarify the requirements and expectations with stakeholders to ensure that you're including or excluding the correct records.

The same concept applies to other time intervals like weeks, months, quarters, and years etc.

The default for this package is exclusive approach, which means when you for instance query for the last 7 days it will not include the current day! You can change the default if you need in the published config file.

Global configuration

You can publish the config file with:

This is the contents of the published config file:

If you want to change the default range to inclusive set DATE_SCOPES_DEFAULT_RANGE=inclusive in your .env.

Fluent date range configuration

As already mentioned above in the default_range config description text, you can also fluently specify the range for quite every scope we offer directly when using the scope:

This will do an inclusive query (today-6 days), even though the global default range here was set to exclusive.

Fluent created_at column configuration

If you only want to change the field in one of your models and not globally just do:

Custom start date

If you want data not starting from now, but from another date, you can do this with:

Scopes

Seconds

Minutes

Hours

Days

Weeks

Months

Quarters

Years

Decades

Centuries

The centuries may return a different range then you maybe would expect. For instance Transaction::ofLastCentury() would apply a range from 1901-01-01 00:00:00 to 2000-12-31 23:59:59. Maybe you would expect a range from: 1900-01-01 00:00:00 to 1999-12-31 23:59:59.

Checkout Wikipedia for this behavior: https://en.wikipedia.org/wiki/20th_century

Millenniums

The millenniums may return a different range then you maybe would expect. For instance Transaction::ofLastMillennium() would apply a range from 1001-01-01 00:00:00 to 2000-12-31 23:59:59. Maybe you would expect a range from: 1000-01-01 00:00:00 to 1999-12-31 23:59:59.

Checkout Wikipedia for this behavior: https://en.wikipedia.org/wiki/2nd_millennium

toNow/toDate

Testing

Upgrading

Please see UPGRADING for details.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-date-scopes with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^9.0 || ^10.0 || ^11.0
illuminate/database Version ^9.0 || ^10.0 || ^11.0
illuminate/support Version ^9.0 || ^10.0 || ^11.0
nesbot/carbon Version ^2.66
spatie/laravel-package-tools Version ^1.13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package laracraft-tech/laravel-date-scopes contains the following files

Loading the files please wait ....