flysquare/laravel-recurring-models
Composer 安装命令:
composer require flysquare/laravel-recurring-models
包简介
Adds Repeatable functionlity to Laravel Models
README 文档
README
Introducing our Laravel Recurring package - the ultimate solution for adding recurring functionality to your Laravel Models! Whether you need simple daily, weekly, or every n days recurrence, or more complex patterns like repeating a model on the second Friday of every month, our package has got you covered. With a seamless integration into your Laravel application, you can easily manage and automate recurring tasks with just a few lines of code.
Installation
You can install the package via composer:
composer require flysquare/laravel-recurring-models
You can publish and run the migrations with:
php artisan vendor:publish --tag="recurring-models-migrations"
php artisan migrate
Usage
Adding the recurring functionality to Models:
- Make sure you models implements
RepeatableContract.
use MohammedManssour\LaravelRecurringModels\Contracts\Repeatable as RepeatableContract; class Task extends Model implements RepeatableContract { }
- Add the
Repeatabletrait to your Model
use MohammedManssour\LaravelRecurringModels\Contracts\Repeatable as RepeatableContract; use MohammedManssour\LaravelRecurringModels\Concerns\Repeatable; class Task extends Model implements RepeatableContract { use Repeatable; }
- Optionaly, customize Model base date.
/** * define the base date that we would use to calculate repetition start_at */ public function repetitionBaseDate(RepetitionType $type = null): Carbon { return $this->created_at; }
Model Recurring rules
The Repeatable trait has repeat method that will help you define the recurrence rules for the model.
The repeat method will return Repeat helper class that has 4 methods: daily, everyNDays, weekly, and complex
1. Daily Recurrence
This will help you to create daily recurring rule for the model.
$model->repeat()->daily()
The recurrence will start the next day based on the repetitionBaseDate returned value.
2. Every N Days Recurrence
This will help you to create every N Days recurring rules for the model.
$model->repeat()->everyNDays(days: 3)
The recurrence will start after n=3 days based on the repetitionBaseDate returned value.
3. Weekly Recurrence
This will help ypi create weekly recurrence rule for the model.
$model->repeat()->weekly()
The recurrence will start after 7 days based on the repetitionBaseDate returned value.
You can specify the days of the recurrence using the on method.
$model->repeat()->weekly()->on(['sunday', 'monday', 'tuesday'])
4. Complex Recurrence.
This will help you create complex recurrence rules for the task.
$model->repeat() ->complex( year: '*', month: '*', day: '*', week: '*', weekOfMonth: '*', weekday: '*' )
Examples
- Repeat model on the second friday of every month.
$model->repeat()->complex(weekOfMonth: 2, weekday: Carbon::FRIDAY)
- Repeat model on the 15th day of every month.
$model->repeat()->complex(day: 15)
Model Scopes
use whereOccurresOn scope to get models that occurres on a specific date.
Task::whereOccurresOn(Carbon::make('2023-05-01'))->get()
use whereOccurresBetween scope to get the models that occurres between two sepcific dates.
Task::whereOccurresBetween(Carbon::make('2023-05-01'), Carbon::make('2023-05-30'))->get()
1. End Recurrance
use endsAt to end occurrance on a specific date
$model->repeat()->daily()->endsAt( Carbon::make('2023-06-01') )
use endsAfter to end occurrance after n times.
$model->repeat()->daily()->endsAfter($times);
2. Start Recurrance
use startsAt method to start occurrance after a specific date.
$model->repeat()->daily()->startsAt( Carbon::make() )
Testing
composer test
Credits
License
The MIT License (MIT). Please see License File for more information.
flysquare/laravel-recurring-models 适用场景与选型建议
flysquare/laravel-recurring-models 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「laravel-recurring-models」 「FlySquare」 「umut can arda」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 flysquare/laravel-recurring-models 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 flysquare/laravel-recurring-models 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 flysquare/laravel-recurring-models 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Adds Repeatable functionlity to Laravel Models
Alfabank REST API integration
Adds Repeatable functionlity to Laravel Models
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-11