Video
Description
Provides a big range of useful date scopes for your Laravel Eloquent models.
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:
use LaracraftTech\LaravelDateScopes\DateScopes; class Transaction extends Model{ use DateScopes;} // query transactions created todayTransaction::ofToday(); // query transactions created during the last weekTransaction::ofLastWeek(); // query transactions created during the start of the current month till nowTransaction::monthToDate(); // query transactions created during the last year, start from 2020Transaction::ofLastYear(startFrom: '2020-01-01'); // ... and much more scopes are available (see below) // For sure, you can chain any Builder function you want here.// Such as these aggregations, for instance:Transaction::ofToday()->sum('amount');Transaction::ofLastWeek()->avg('amount');
Related Content on Laravel Daily
Video
Recent Courses on Laravel Daily
[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Testing in Laravel 13 For Beginners
26 lessons
1 h 41 min read
How to Build Laravel 13 API From Scratch
30 lessons
1 h 23 min