Search by

jingulab / laravel-date-scopes

jintack81

A lightweight Laravel package providing common Eloquent date scopes.

Package info

github.com/jintack81/laravel-date-scopes

pkg:composer/jingulab/laravel-date-scopes

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-11-10 10:04 UTC

This package is auto-updated.

Last update: 2026-11-10 10:04:25 UTC


README

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.