Vous cherchez à embaucher des développeurs Laravel ? Essayez LaraJobs

laravel-date-scopes maintained by jingulab

Description
A lightweight Laravel package providing common Eloquent date scopes.
Last update
2026/11/10 11:04 (dev-main)
License
Links
Downloads
0

Comments
comments powered by Disqus

Laravel Date Scopes

Latest Version on Packagist Total Downloads License

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.