jingulab / laravel-date-scopes
A lightweight Laravel package providing common Eloquent date scopes.
dev-main
2026-11-10 10:04 UTC
Requires
- php: ^8.2
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-10 10:04:25 UTC
README
A lightweight Laravel package that provides convenient date-based Eloquent scopes for your models.
Requirements
- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x
Installation
You can install the package via Composer:
composer require jingulab/laravel-date-scopes
Usage
Add the HasDateScopes trait to your Eloquent model:
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Jingulab\LaravelDateScopes\Traits\HasDateScopes; class Post extends Model { use HasDateScopes; }
Available Scopes
Now you can easily query records by date:
// Filter by specific dates or ranges $todayPosts = Post::whereToday()->get(); $yesterdayPosts = Post::whereYesterday()->get();$thisMonthPosts = Post::whereThisMonth()->get(); // Custom column support (default is 'created_at') $publishedToday = Post::whereToday('published_at')->get();
Testing
Run tests using PHPUnit:
composer test
License
The MIT License (MIT). Please see License File for more information.