PHPackages                             mohammedmanssour/failed-jobs-model - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. mohammedmanssour/failed-jobs-model

ActiveLibrary[Queues &amp; Workers](/categories/queues)

mohammedmanssour/failed-jobs-model
==================================

An Eloquent model, query scopes, and Artisan commands to inspect, analyze, and prune Laravel's failed\_jobs table — with an indexed display\_name for fast lookups and stats.

v1.1.0(1mo ago)11MITPHPPHP ^8.3CI passing

Since Jun 23Pushed 1mo agoCompare

[ Source](https://github.com/mohammedmanssour/failed-jobs-model)[ Packagist](https://packagist.org/packages/mohammedmanssour/failed-jobs-model)[ Docs](https://github.com/mohammedmanssour/failed-jobs-model)[ RSS](/packages/mohammedmanssour-failed-jobs-model/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (2)Dependencies (16)Versions (3)Used By (0)

Failed Jobs Model
=================

[](#failed-jobs-model)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f57b6c26c0f91ae18ab3e35c8bf5ad2e703d031fc1b6ec3275050be782bef726/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f68616d6d65646d616e73736f75722f6661696c65642d6a6f62732d6d6f64656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohammedmanssour/failed-jobs-model)[![Tests](https://github.com/mohammedmanssour/failed-jobs-model/actions/workflows/run-tests.yml/badge.svg)](https://github.com/mohammedmanssour/failed-jobs-model/actions/workflows/run-tests.yml)

An Eloquent model, query scopes, and Artisan commands to inspect, analyze, and prune Laravel's `failed_jobs` table — with an indexed `display_name` for fast lookups and stats.

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

[](#installation)

```
composer require mohammedmanssour/failed-jobs-model
```

The package adds a `display_name` column (a generated column derived from `payload->displayName`) and a compound index on `[display_name, failed_at]` — so class-name lookups also satisfy the default `failed_at` ordering from the same index, with no filesort. The migration runs automatically with:

```
php artisan migrate
```

> Supports MySQL, PostgreSQL, and SQLite. On MySQL/SQLite the column is `VIRTUAL`; on PostgreSQL it is `STORED`.

Optionally publish the config and migration:

```
php artisan vendor:publish --tag="failed-jobs-model-config"
php artisan vendor:publish --tag="failed-jobs-model-migrations"
```

The model
---------

[](#the-model)

`MohammedManssour\FailedJobsModel\FailedJob` maps to the `failed_jobs` table.

```
use MohammedManssour\FailedJobsModel\FailedJob;

$job = FailedJob::findByJobId($uuid);   // single job by uuid, or null

$job->display_name;   // e.g. "App\Jobs\SendEmail" (indexed)
$job->payload;        // decoded payload object
$job->command;        // the unserialized job command instance
$job->exception;      // exception text
$job->failed_at;      // Carbon instance
```

Every query is ordered by `failed_at` descending by default.

### Scopes

[](#scopes)

```
// Jobs for a given class name (uses the indexed display_name column)
FailedJob::whereDisplayName('App\Jobs\SendEmail')->get();
FailedJob::findByDisplayName('App\Jobs\SendEmail'); // shortcut, latest first

// Search the exception text (case-insensitive)
FailedJob::whereExceptionContains('Connection timed out')->get();

// Drop the default failed_at ordering (e.g. for aggregations)
FailedJob::withoutLatestFailed()->get();
```

Commands
--------

[](#commands)

```
# Most frequently failing jobs (defaults to top 5)
php artisan failed-jobs:stats --top=10

# Row count and total size of the failed_jobs table
php artisan failed-jobs:size

# Prune failed jobs older than N hours (falls back to config)
php artisan failed-jobs:prune --hours=24
```

Scheduled pruning
-----------------

[](#scheduled-pruning)

The package schedules `queue:prune-failed` for you, configured via `config/failed-jobs-model.php`:

```
'pruning' => [
    'enabled' => env('FAILED_JOBS_PRUNE_ENABLED', true),
    'hours' => (int) env('FAILED_JOBS_PRUNE_HOURS', 168),       // delete jobs older than 7 days
    'at' => env('FAILED_JOBS_PRUNE_AT', '01:00'),                // daily run time
    'environments' => [...],                                     // limit to these envs (empty = all)
],
```

Testing
-------

[](#testing)

```
composer test
```

The suite runs on in-memory SQLite by default. To run it against MySQL or PostgreSQL, copy `.env.example` to `.env` and set the `DB_*` values.

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~4 days

Total

2

Last Release

42d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aeb75f35979097845cce704062910a6a8c85bc0a7b49b081df7350a4f20023fc?d=identicon)[manssour.mohammed](/maintainers/manssour.mohammed)

---

Top Contributors

[![mohammedmanssour](https://avatars.githubusercontent.com/u/19733629?v=4)](https://github.com/mohammedmanssour "mohammedmanssour (4 commits)")

---

Tags

laravelfailed jobslaravel-queuequeue monitoringfailed-jobs-model

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mohammedmanssour-failed-jobs-model/health.svg)

```
[![Health](https://phpackages.com/badges/mohammedmanssour-failed-jobs-model/health.svg)](https://phpackages.com/packages/mohammedmanssour-failed-jobs-model)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

13.0k107.5M1.6k](/packages/spatie-laravel-permission)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.2k12.6M128](/packages/dedoc-scramble)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k5.4M49](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329575.9k33](/packages/codewithdennis-filament-select-tree)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

25060.1k](/packages/vormkracht10-laravel-mails)

PHPackages © 2026

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