定制 apility/rule-builder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

apility/rule-builder

最新稳定版本:v1.5.2

Composer 安装命令:

composer require apility/rule-builder

包简介

README 文档

README

Installation

composer require apility/rule-builder

Example usage

<?php

use Carbon\Carbon;
use Netflex\RuleBuilder\DateRules\DateRule;

// Example of a rule that matches any dates in the year 2021 except the 17th of May, 24th of December and the month of June.
$rule = DateRule::parse([
    'type' => 'group',
    'count' => 'all',
    'children' => [
        [
            'type' => 'group',
            'count' => 'any',
            'children' => [
                [
                    'type' => 'dateRange',
                    'from' => '2021-01-01',
                    'to' => '2022-01-01'
                ]
            ]
        ],
        [
            'type' => 'not',
            'child' => [
                'type' => 'group',
                'count' => 'any',
                'children' => [
                    [
                        'name' => '17th of May',
                        'type' => 'dateRange',
                        'from' => '2021-05-17',
                        'to' => '2021-05-18'
                    ]
                    [
                        'name' => 'Christmas',
                        'type' => 'dateRange',
                        'from' => '2021-12-24',
                        'to' => '2021-12-25'
                    ],
                    [
                        'name' => 'Closed for the summer',
                        'type' => 'dateRange',
                        'from' => '2021-06-01',
                        'to' => '2021-07-01'
                    ]
                ]
            ]
        ]
    ]
]);

$validated = $rule->validate(Carbon::parse('2021-11-20'));

if ($validated) {
    // The rule matched the given date
}
<?php

use Carbon\Carbon;
use Netflex\RuleBuilder\DateRules\DateRule;

// Example of a rule that matches every saturday and sunday in the month of September in the year 2021.
$rule = DateRule::parse([
    'type' => 'group',
    'count' => 'all',
    'children' => [
        [
            'type' => 'dateRange',
            'from' => '2021-09-01',
            'to' => '2022-10-01'
        ],
        [
            'type' => 'dayOfWeek',
            'days' => [6, 0]
        ]
    ]
]);

$validated = $rule->validate(Carbon::parse('2021-09-22'));

if ($validated) {
    // The rule matched the given date
}

统计信息

  • 总下载量: 5.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-22