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
Roles and Permissions in Laravel 13
14 lessons
57 min
Queues in Laravel 13
18 lessons
1 h 12 min read
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read