Skip to content

apility/filament-daterules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Date Rule Builder for Laravel Filament

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a flexible date rule builder for Laravel Filament applications. It allows you to create complex date validation rules through a user-friendly interface.

Key features:

  • Build compound date rules using logical operators (AND/OR)
  • Multiple rule types available:
    • Date ranges
    • Specific dates
    • Days of week
    • Holidays
    • Weekly patterns
    • Exceptions
    • Leap days
    • Conditional rules
  • Fully integrated with Filament forms
  • Rules are serializable to JSON for storage
  • Easy to extend with custom rule types

The date rule builder can be used to create sophisticated date validation logic, such as:

  • Business hours and holiday schedules
  • Event availability patterns
  • Date-based access control
  • Custom calendar rules

Each rule implements a passes() method that checks if a given date matches the rule's criteria. Rules can be combined using AND/OR operators and can include exceptions. The builder component provides an intuitive interface for constructing these rule sets within your Filament forms.

Installation

You can install the package via composer:

composer require apility/filament-daterules

Usage

** TODO **

Creating Custom Rules

You can extend the date rule system with your own custom rules. To create a custom rule:

  1. Create a class that implements the Apility\DateRules\Contracts\DateRule interface, implement the following methods
    • passes(CarbonImmutable $date): bool - Determines if the date matches the rule
    • bounds(): ?CarbonPeriodImmutable - Optional method to specify date bounds
  2. If you want to use this custom rule in Filament, we recommend extending from the abstract Apility\DateRules\Rules\Rule class, and implement the following method
    • block(): Block - Defines the Filament form fields for configuring the rule
  3. Anywhere you want to include this custom rule, define what rules the DateRules component should includes (example below)
use Apility\DateRules\Filament\Forms\Components\DateRules;
...
DateRules::make('my-date-rules')
    ->

Here's an example of a custom rule for checking if a date is July 4th:

<?php

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages