PHPackages                             sinclairt/schedulable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sinclairt/schedulable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sinclairt/schedulable
=====================

Schedule any object with schedulable

2.0.1(9y ago)1122MITPHP

Since Aug 18Pushed 9y agoCompare

[ Source](https://github.com/sinclairt/schedulable)[ Packagist](https://packagist.org/packages/sinclairt/schedulable)[ RSS](/packages/sinclairt-schedulable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (11)Used By (0)

Schedulable
===========

[](#schedulable)

### Installation

[](#installation)

- Run `composer require sinclairt/schedulable`.
- Register `Sinclair\Schedulable\Providers\SchedulableServiceProvider::class` in `config\app.php` inside the `providers` array.
- Run `composer dump-autoload`
- Run `php artisan vendor:publish`. This will publish the migration for the schedules.
- Run `php artisan migrate`

### Usage

[](#usage)

Use the `IsSchedulable` trait inside your model. This will give you access to a host of scopes and methods.

##### Create Schedules

[](#create-schedules)

Use the helper method to start building your schedules fluently.

```
schedule($object)->daily()->hour(10)->minute(0)->save();

```

##### Update Schedules

[](#update-schedules)

If your object already has a schedule attached, then when you make changes, and save, the changes will be made to the existing schedule.

##### Available Fields

[](#available-fields)

```
 minutely()
 hourly()
 daily()
 weekly()
 monthly()
 annually()
 quarterly()
 adhoc()
 isMinutely()
 isHourly()
 isDaily()
 isWeekly()
 isMonthly()
 isAnnually()
 isQuarterly()
 isAdhoc()
 minute( $value = null )
 hour( $value = null )
 dayOfWeek( $value = null )
 dayOfMonth( $value = null )
 monthOfYear( $value = null )
 year( $value = null )
 isLastDayOfMonth( $value = null )
 frequencyN( $value = null )
 startsAt( $value = null )
 expiresAt( $value = null )

```

###### Dynamic setting/getting

[](#dynamic-settinggetting)

This factory uses dynamic methods, so be aware, for example, calling `schedule($object)->hour()` will return the current hour stored on the schedule factory, however, calling `schedule($object)->hour(10)` will set the hour property to `10` and return the factory for you to keep chaining.

###### Starts At/Expires At

[](#starts-atexpires-at)

You can set when a schedule should start and end, this is optional. The active/expired scopes will take notice of these fields.

###### Shortcuts

[](#shortcuts)

`loadFromSchedule($schedule = null)` - this will load all the attributes from the supplied schedule into the factory. It will also set the factory's schedule object to the schedule supplied. If no schedule is supplied then it will use the currently attached schedule i.e.

```
schedule($objectWithoutSchedule)->loadFromSchedule($anotherSchedule);
// or
schedule($objectWithoutSchedule)->setSchedule($schedule)->loadFromSchedule();

```

`resetSchedule()` - will reset all the properties to their default regardless of the object(s) attached to the factory.

`refresh()` - will return a new instance of the factory with the current object inside it.

`loadFromCron($string)` - will set the properties from a cron expression to the factory. You can use pseudo expressions:

- @annually
- @monthly
- @weekly
- @daily
- @hourly

##### Getting dates

[](#getting-dates)

You can get the `next()` date, `previous()` date, `nextRunDates($n)`, `previousRunDates($nth)` (where `$n` is the number of dates you need i.e. 3). You can also get the potential run dates between two dates as well with `runDatesBetween(Carbon $from, Carbon $to, bool $active = true)`.

##### Running schedules

[](#running-schedules)

When a schedule has run it is a good idea to run the `hasRun()` method, because this will update the `last_run_at` and `next_runs_at` timestamps.

##### Scopes

[](#scopes)

There a huge number of scopes available to you:

```

dueOn( Carbon $dt, $active = true )
isNow()
isMinutely()
isHourly()
isDaily()
isWeekly()
isMonthly()
isAnnually()
isQuarterly()
isAdhoc()
between( Carbon $dtFrom, Carbon $dtTo = null, $active = true )
day( Carbon $dt )
dayBetween( Carbon $dtFrom, Carbon $dtTo = null )
dayOfMonth( int $day )
dayOfMonthBetween( Carbon $dtFrom, Carbon $dtTo = null )
dayOfWeek( int $day )
dayOfWeekBetween( Carbon $dtFrom, Carbon $dtTo = null )
lastOfMonth( Carbon $dt )
month( int $month )
monthBetween( int $from, int $to )
year( int $year )
yearBetween( int $from, int $to )
hour( int $hour )
hourBetween( int $from, int $to )
minute( int $minute )
minuteBetween( int $from, int $to )
isActive( Carbon $dt = null )
isActiveBetween( Carbon $dtFrom, Carbon $dtTo = null )
isExpired( Carbon $dt = null )

```

### Disclaimer

[](#disclaimer)

Although a lot of time and effort has gone into making the *between* scopes and methods, it does have its limitations, as the dates are calculated on the fly, so be careful when using them, as they could cause a memory failure in your script.

### Other Methods

[](#other-methods)

- `hasSchedule()` - determines whether your object has a schedule attached
- `isDue( Carbon $dt = null )` - is the schedule due on a specific date, or if `$dt` is blank now.
- `getScheduleType( $schedule )` - (on the Schedule model)
- `allRunDatesBetween( Carbon $dtFrom, Carbon $dtTo = null, $active = true )` - (on the Schedule model) - all dates that all the schedules could run.
- `setSchedule()` - (ScheduleFactory)
- `getSchedule()` - (ScheduleFactory)
- `setObject()` - (ScheduleFactory)
- `getObject()` - (ScheduleFactory)
- `load()` - (ScheduleFactory) - this will take the current objects schedule and set all the properties.

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~24 days

Recently: every ~47 days

Total

10

Last Release

3328d ago

Major Versions

1.0.7 → 2.0.02016-12-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0dc010eef4e76d1eb705b4f2257422302ada2164add753976f7998d9203b19a?d=identicon)[sinclairt](/maintainers/sinclairt)

---

Top Contributors

[![sinclairt](https://avatars.githubusercontent.com/u/16877448?v=4)](https://github.com/sinclairt "sinclairt (2 commits)")[![tom-sinclair](https://avatars.githubusercontent.com/u/23167798?v=4)](https://github.com/tom-sinclair "tom-sinclair (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sinclairt-schedulable/health.svg)

```
[![Health](https://phpackages.com/badges/sinclairt-schedulable/health.svg)](https://phpackages.com/packages/sinclairt-schedulable)
```

###  Alternatives

[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[intervention/zodiac

Zodiac Sign Calculator

58191.7k](/packages/intervention-zodiac)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[solspace/craft-calendar

The most powerful event management and calendaring plugin!

1830.8k1](/packages/solspace-craft-calendar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
