When you filter and query eloquent models by given dates, you may often use similar ranges, especially in statistics or analysis. Here our package Laravel Date Scopes comes in to play. It lets you conveniently filter by date, with common statistical ranges.
You can easily install the package by requiring it via composer:
composer require laracraft-tech/laravel-date-scopes
Let's assume you have an Transaction model class. Now when you give it the DateScopes trait (which comes with the package), you can use the following scopes:
For a full list of available ranges, checkout the documentation here!
It's important to understand this difference:
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.
The rich text element allows you to create and format headings, paragraphs, blockquotes, images, and video all in one place instead of having to add and format them individually. Just double-click and easily create content.
A rich text element can be used with static or dynamic content. For static content, just drop it into any page and begin editing. For dynamic content, add a rich text field to any collection and then connect a rich text element to that field in the settings panel. Voila!
Headings, paragraphs, blockquotes, figures, images, and figure captions can all be styled after a class is added to the rich text element using the "When inside of" nested selector system.
composer require spatie/laravel-artisan-dispatchable