PHPackages                             muhammedalkhudiry/laravel-long-term-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. muhammedalkhudiry/laravel-long-term-tasks

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

muhammedalkhudiry/laravel-long-term-tasks
=========================================

This is my package laravel-long-term-tasks

0.0.2(1y ago)18[5 PRs](https://github.com/MuhammedAlkhudiry/laravel-long-term-tasks/pulls)MITPHPPHP ^8.2CI passing

Since Aug 3Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/MuhammedAlkhudiry/laravel-long-term-tasks)[ Packagist](https://packagist.org/packages/muhammedalkhudiry/laravel-long-term-tasks)[ Docs](https://github.com/muhammedalkhudiry/laravel-long-term-tasks)[ GitHub Sponsors]()[ RSS](/packages/muhammedalkhudiry-laravel-long-term-tasks/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (14)Versions (8)Used By (0)

Laravel Long Term Tasks
=======================

[](#laravel-long-term-tasks)

[![Latest Version on Packagist](https://camo.githubusercontent.com/380a82a2a0985b85273d650ac495cad9a157358d991c0629f478e01da90e5baa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7568616d6d6564616c6b6875646972792f6c61726176656c2d6c6f6e672d7465726d2d7461736b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhammedalkhudiry/laravel-long-term-tasks)[![GitHub Tests Action Status](https://camo.githubusercontent.com/83a2cf87375ac21c2af8670fe5cf6dc90160562d33e584ee37b79f834a150b1d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7568616d6d6564616c6b6875646972792f6c61726176656c2d6c6f6e672d7465726d2d7461736b732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/muhammedalkhudiry/laravel-long-term-tasks/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/8a41afa34ded8815030f955aa79c09c44bfa1bc032b7fbb370d2a35903f5e3a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7568616d6d6564616c6b6875646972792f6c61726176656c2d6c6f6e672d7465726d2d7461736b732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/muhammedalkhudiry/laravel-long-term-tasks/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e9632360d47500eda28f820a6b06775cc7aaa2dcd719857abb8a961a40ad7852/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7568616d6d6564616c6b6875646972792f6c61726176656c2d6c6f6e672d7465726d2d7461736b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhammedalkhudiry/laravel-long-term-tasks)

This package handles common cases where you must run a long-term task.

- Example: Delete a user account after 30 days of inactivity

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

[](#installation)

You can install the package via composer:

```
composer require muhammedalkhudiry/laravel-long-term-tasks
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="long-term-tasks-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="long-term-tasks-config"
```

This is the contents of the published config file:

```
return [
    'model' => \MuhammedAlkhudiry\LaravelLongTermTasks\Models\LongTermTask::class,
];
```

Overview
--------

[](#overview)

Let's say you have a client who should have multiple payments, and we have to submit his/her first payment, You want to remind him/her to submit the second payment within 30 days.

Typically, you would create a command that checks the database for users who have not submitted the second payment and send them a reminder email and run this command in the schedule.

(The logic here can be more complex, like checking if the user has a valid subscription, if the user has a valid payment method, etc.)

```
// App\Console\Kernel.php
$schedule->command('second-payment-reminder:send')->everyMinute();

// App\Console\Commands\SecondPaymentReminder.php
public function handle()
{
      Payment::query()
        ->where('type', PaymentType::FIRST->value)
        ->where('is_customer_notified', false)
        ->each(
          function (Payment $payment) {
            if ($payment->next_payment_at?->isToday()) {
              $payment->customer->notify(new SecondPaymentReminderNotification($payment));
              $payment->update(['is_customer_notified' => true]);
            }
          }
        );
}
```

using this package, you can create a task that will be executed after 30 days, and you can handle the logic in the task itself.

```
schedule(new \App\Jobs\SecondPaymentReminder())
    ->on(now()->addDays(30))
    ->name("second-payment-{$payment->id}")
    ->save();
```

And that's it! ✨

Let's say the user refunded the first payment, you can delete the task using the task name.

```
\MuhammedAlkhudiry\LaravelLongTermTasks\TaskScheduler::delete("second-payment-{$payment->id}");
```

Usage
-----

[](#usage)

### Add the command to your schedule

[](#add-the-command-to-your-schedule)

```
$schedule->command('long-term-tasks:process')->everyMinute(); // You can change the frequency depending on your needs
```

### Create a Task

[](#create-a-task)

```
schedule(new \App\Jobs\SecondPaymentReminder())
    ->on(now()->addDays(1)) // Required, the date when the task should be executed
    ->name("second-payment-{$payment->id}") // Optional, you can use it later to delete/update the task
    ->then(function ($task) {
        // When the task is executed
    })
    ->catch(function ($task, $exception) {
        // When the task failed
    })
    ->finally(function ($task) {
        // When the task is executed or failed
    })
    ->shouldQueue() // Optional, by default it will run synchronously
    ->save(); // Required, to save the task
```

Note

`then`, `catch`, and `finally` will be serialized.

### Delete a Task

[](#delete-a-task)

```
    \MuhammedAlkhudiry\LaravelLongTermTasks\TaskScheduler::delete("second-payment-{$payment->id}");
```

### Update a Task

[](#update-a-task)

```
\MuhammedAlkhudiry\LaravelLongTermTasks\TaskScheduler::get("second-payment-{$payment->id}")
    ->on(now()->addDays(1))
    ->update();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [muhammed alkhudiry](https://github.com/MuhammedAlkhudiry)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance66

Regular maintenance activity

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.4% 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 ~1 days

Total

2

Last Release

646d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/214204f594dca2d14876ce8ce1d52b48841fe77b18f2c7e02a05a7ae1daf0d92?d=identicon)[MuhammedAlkhudiry](/maintainers/MuhammedAlkhudiry)

---

Top Contributors

[![MuhammedAlkhudiry](https://avatars.githubusercontent.com/u/41856121?v=4)](https://github.com/MuhammedAlkhudiry "MuhammedAlkhudiry (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelmuhammed alkhudirylaravel-long-term-tasks

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/muhammedalkhudiry-laravel-long-term-tasks/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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