Projects

Laravel Tasks

Laravel package Maintained

Attach scheduled tasks to any Eloquent model and run commands, actions, events or service methods at a set time.

GitHubPackagist

PHP 8.2+, Laravel 11–13

Getting started

Requirements

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

Install

composer require michal78/laravel-tasks
php artisan migrate

Optionally publish the config:

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

Add the trait

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

class User extends Model
{
    use HasTasks;
}

Schedule a command task

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

The package injects --model-type (the model class) and --model-id (the model’s primary key) into the command automatically.

The full reference is in the README on GitHub.