承接 whilesmart/eloquent-scheduling 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

whilesmart/eloquent-scheduling

Composer 安装命令:

composer require whilesmart/eloquent-scheduling

包简介

Attach one-shot or recurring (RRULE) schedules to any Eloquent model and fire them through a runner event.

README 文档

README

Attach a schedule to any Eloquent model and fire it when it is due. One model, two modes: a one-shot that runs once at a set time, or a recurring schedule driven by an RRULE. A runner command fires every due schedule and emits an event your app listens for, so the same substrate powers recurring transactions, reminders, digests, and recurring agent actions. Each schedule is scoped to an owner (a workspace, organization, user) through whilesmart/eloquent-owner-access.

Install

composer require whilesmart/eloquent-scheduling
php artisan migrate

Routes register automatically under the api prefix with auth:sanctum. Set SCHEDULING_REGISTER_ROUTES=false to mount them yourself.

Attaching schedules

Schedulable gives a model the schedules pointed at it (the thing being scheduled); HasSchedules gives an owner the schedules it owns.

use Whilesmart\Scheduling\Traits\Schedulable;

class Invoice extends Model
{
    use Schedulable;
}

$invoice->schedules()->create([
    'owner_type' => Workspace::class,
    'owner_id' => $workspace->id,
    'mode' => 'recurring',
    'rrule' => 'FREQ=MONTHLY;BYMONTHDAY=1',
    'timezone' => 'Europe/Berlin',
]);

next_run_at is computed when the schedule is created (from run_at for a one-shot, or the first RRULE occurrence for a recurring one) and advanced each time it fires.

Firing due schedules

Run the command every minute from the host scheduler:

// app/Console/Kernel.php (or bootstrap/app.php on Laravel 11+)
$schedule->command('schedules:run')->everyMinute();

schedules:run loads every due schedule, dispatches Whilesmart\Scheduling\Events\ScheduleDue($schedule), then advances it: a one-shot deactivates, a recurring schedule moves to its next occurrence. Listen for the event to do the actual work:

use Whilesmart\Scheduling\Events\ScheduleDue;

Event::listen(function (ScheduleDue $event) {
    $schedule = $event->schedule;      // owner, schedulable, metadata
    // post the recurring transaction, send the reminder, run the agent action...
});

Endpoints

Method Path Purpose
GET /api/schedules List (filter by mode, active, due, owner, schedulable)
POST /api/schedules Create
GET /api/schedules/{schedule} Show
PUT/PATCH /api/schedules/{schedule} Update
DELETE /api/schedules/{schedule} Soft delete

Modes

ScheduleMode: once, recurring. A one-shot needs run_at; a recurring schedule needs an rrule (any string rlanvin/php-rrule accepts, e.g. FREQ=WEEKLY;BYDAY=MO) and honours timezone.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固