PHPackages                             michal78/laravel-tasks - 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. michal78/laravel-tasks

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

michal78/laravel-tasks
======================

Scheduled model tasks for Laravel

1.0.0.3(1y ago)27MITPHPPHP ^7.4|^8.0|^8.1|^8.2CI passing

Since May 18Pushed 6d ago1 watchersCompare

[ Source](https://github.com/michal78/laravel-tasks)[ Packagist](https://packagist.org/packages/michal78/laravel-tasks)[ Docs](https://github.com/michal78/laravel-tasks)[ RSS](/packages/michal78-laravel-tasks/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (6)Dependencies (5)Versions (20)Used By (0)

Laravel Tasks
=============

[](#laravel-tasks)

`michal78/laravel-tasks` lets you attach scheduled tasks to any Eloquent model.

A task can run one of four target types at a specific time:

- Artisan command
- Action class
- Event class
- Service class method

The model is always passed into the target, and task runs can be logged (optional).

[![Latest Version on Packagist](https://camo.githubusercontent.com/ab2ee3fab4caad6323c62d75b7a07c1bd7f96a55d7f4e3044772c31394f34b4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696368616c37382f6c61726176656c2d7461736b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/michal78/laravel-tasks)[![Total Downloads](https://camo.githubusercontent.com/ecc6c8b21092300d05fc979e96501bc8988c6ed06f76c6159aa0c10cabd91a03/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d696368616c37382f6c61726176656c2d7461736b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/michal78/laravel-tasks)

Requirements
------------

[](#requirements)

- PHP 8.2+ (Laravel 13 requires PHP 8.3+)
- Laravel 11, 12, or 13

Installation
------------

[](#installation)

```
composer require michal78/laravel-tasks
```

Run migrations:

```
php artisan migrate
```

Optional config publish:

```
php artisan vendor:publish --provider="Michal78\Tasks\TasksServiceProvider" --tag=config
```

Model Setup
-----------

[](#model-setup)

Add the trait to any model:

```
use Illuminate\Database\Eloquent\Model;
use Michal78\Tasks\Traits\HasTasks;

class User extends Model
{
    use HasTasks;
}
```

Scheduling Tasks
----------------

[](#scheduling-tasks)

### Command task

[](#command-task)

```
$user->scheduleCommandTask(
    name: 'Sync user',
    command: 'users:sync',
    runAt: now()->addMinutes(10),
    payload: ['--force' => true],
);
```

The package injects these command options automatically:

- `--model-type` (model class)
- `--model-id` (model primary key)

### Action task

[](#action-task)

```
$user->scheduleActionTask(
    name: 'Run action',
    actionClass: \App\Actions\UserAction::class,
    runAt: now()->addHour(),
    payload: ['source' => 'onboarding'],
);
```

Default method is `__invoke`. You can pass a custom method with the `method` argument.

### Event task

[](#event-task)

```
$user->scheduleEventTask(
    name: 'Dispatch event',
    eventClass: \App\Events\UserTaskDue::class,
    runAt: now()->addMinutes(30),
    payload: ['channel' => 'email'],
);
```

Event constructor signature should accept:

```
public function __construct(Model $model, array $payload, Task $task)
```

### Service task

[](#service-task)

```
$user->scheduleServiceTask(
    name: 'Call service',
    serviceClass: \App\Services\UserTaskService::class,
    runAt: now()->addDay(),
    payload: ['dry_run' => false],
    method: 'handle', // optional, defaults to handle
);
```

Running Due Tasks
-----------------

[](#running-due-tasks)

The package registers:

```
php artisan tasks:run-due
```

Add it to Laravel scheduler:

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('tasks:run-due')->everyMinute();
```

Task Logging (Optional)
-----------------------

[](#task-logging-optional)

Each run can be logged in `task_logs`.

Config:

```
// config/laravel-tasks.php
return [
    'logging' => [
        'enabled' => env('TASKS_LOGGING_ENABLED', true),
    ],
];
```

When enabled, each task run stores status (`running`, `succeeded`, `failed`), start/end timestamps, and optional error message.

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance77

Regular maintenance activity

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 87.9% 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 ~378 days

Total

3

Last Release

386d ago

PHP version history (2 changes)1.0.0.0PHP ^7.4|^8.0

1.0.0.3PHP ^7.4|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/27c8fa2ab59c3e8cbaf0c8d4638b6f2b16cf6104ad54e568824eeab753bd0d59?d=identicon)[michal78](/maintainers/michal78)

---

Top Contributors

[![michal78](https://avatars.githubusercontent.com/u/239061?v=4)](https://github.com/michal78 "michal78 (29 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (4 commits)")

---

Tags

laravel-tasksmichal78

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michal78-laravel-tasks/health.svg)

```
[![Health](https://phpackages.com/badges/michal78-laravel-tasks/health.svg)](https://phpackages.com/packages/michal78-laravel-tasks)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.9k1](/packages/mike-bronner-laravel-model-caching)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

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