PHPackages                             putheakhem/approval-workflow - 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. putheakhem/approval-workflow

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

putheakhem/approval-workflow
============================

Flexible approval workflow engine for Laravel (approval chain, steps, parallel approvals, audit trail).

1.0.1(5mo ago)5291[1 PRs](https://github.com/putheakhem/approval-workflow/pulls)MITPHPPHP ^8.2CI passing

Since Jan 13Pushed 4mo agoCompare

[ Source](https://github.com/putheakhem/approval-workflow)[ Packagist](https://packagist.org/packages/putheakhem/approval-workflow)[ RSS](/packages/putheakhem-approval-workflow/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

[![Tests](https://github.com/putheakhem/approval-workflow/actions/workflows/tests.yml/badge.svg)](https://github.com/putheakhem/approval-workflow/actions/workflows/tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/bb4c913483a87a030b97032636b311cbcdcf46ec438ed1a56abca76938b96a5c/68747470733a2f2f706f7365722e707567782e6f72672f7075746865616b68656d2f617070726f76616c2d776f726b666c6f772f762f737461626c65)](https://packagist.org/packages/putheakhem/approval-workflow)[![License](https://camo.githubusercontent.com/f88223d1cba48c295781450d3f454b2e401651ca8a9a17dc47b6a5bc5451fe8e/68747470733a2f2f706f7365722e707567782e6f72672f7075746865616b68656d2f617070726f76616c2d776f726b666c6f772f6c6963656e7365)](https://packagist.org/packages/putheakhem/approval-workflow)

---

🇰🇭 Stand with Cambodia • កម្ពុជា
--------------------------------

[](#-stand-with-cambodia--កម្ពុជា)

### 🕊️ **Cambodia Needs Peace** 🕊️

[](#️-cambodia-needs-peace-️)

We stand in solidarity with our brave soldiers defending Cambodia's sovereignty and territorial integrity. Our hearts are with those protecting our homeland during these challenging times. We call upon the international community to support peaceful resolution and respect for Cambodia's borders.

**🙏 កម្ពុជាត្រូវការសន្តិភាព • Together we stand for peace and sovereignty**

--- Approval Workflow for Laravel
=============================

[](#approval-workflow-for-laravel)

A flexible, database-driven approval workflow engine for Laravel applications. It supports multi-step approval chains, parallel approvals, SLA monitoring, and dynamic assignment.

Features
--------

[](#features)

- **Multiple Workflow Versions**: Define and evolve workflows over time without breaking existing instances.
- **Dynamic Assignment**: Assign tasks to users, roles (Spatie Permission integration), or managers.
- **Flexible Modes**: Support for 'any' (one person approves) or 'all' (consensus required) modes.
- **SLA Monitoring**: Built-in support for task deadlines and breach recording.
- **Delegation**: Automatic redirection of tasks based on user availability (vacation/out-of-office).
- **Audit Trail**: Detailed event logging (started, assigned, acted, breached, completed) for every action.
- **Conditional Transitions**: Override default flow based on actions (approve/reject/changes\_requested).

Documentation
-------------

[](#documentation)

For detailed documentation, please visit

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

[](#installation)

Add the package to your `composer.json` or install it via composer:

```
composer require putheakhem/approval-workflow
```

Detailed Examples
-----------------

[](#detailed-examples)

For practical code snippets of each feature, check out the [EXAMPLES.md](EXAMPLES.md) file.

Setup
-----

[](#setup)

1. **Publish Configuration &amp; Migrations**:

```
php artisan vendor:publish --provider="PutheaKhem\ApprovalWorkflow\ApprovalWorkflowServiceProvider"
```

2. **Run Migrations**:

```
php artisan migrate
```

3. **Configure the User Model**: Ensure `config/approval-workflow.php` points to your User model (usually `App\Models\User`).
4. **Add the Trait**: Add the `HasWorkflow` trait to any Eloquent model that requires an approval process:

```
use PutheaKhem\ApprovalWorkflow\Concerns\HasWorkflow;

class ExpenseClaim extends Model
{
    use HasWorkflow;
}
```

Usage
-----

[](#usage)

### 1. Defining a Workflow

[](#1-defining-a-workflow)

Workflows are stored in the database. You typically create them via a seeder or an admin UI.

```
use PutheaKhem\ApprovalWorkflow\Models\Workflow;
use PutheaKhem\ApprovalWorkflow\Models\WorkflowVersion;

$workflow = Workflow::create(['key' => 'expense-approval', 'name' => 'Expense Approval']);

WorkflowVersion::create([
    'workflow_id' => $workflow->id,
    'version' => 1,
    'published_at' => now(),
    'definition' => [
        'steps' => [
            ['key' => 'start', 'type' => 'start', 'next' => 'manager_step'],
            [
                'key' => 'manager_step',
                'name' => 'Manager Approval',
                'assignment' => ['type' => 'manager_of', 'field' => 'requester_id'],
                'next' => 'end'
            ],
            ['key' => 'end', 'type' => 'end'],
        ],
    ],
]);
```

### 2. Starting a Workflow

[](#2-starting-a-workflow)

```
$expense = ExpenseClaim::create([...]);
$instance = $expense->startWorkflow('expense-approval', [
    'requester_id' => auth()->id(),
    'amount' => 500
]);
```

### 3. Approving / Rejecting

[](#3-approving--rejecting)

Tasks are created for each step. Approvers can act on these tasks.

```
use PutheaKhem\ApprovalWorkflow\Services\ApprovalService;

$service = app(ApprovalService::class);
$task = $instance->currentTasks()->first();

$service->approve($instance, $task->id, auth()->id(), 'Looks good!');
```

### 4. Checking Status

[](#4-checking-status)

```
if ($expense->isApproved()) {
    // Logic for approved expense
}

if ($expense->isRejected()) {
    // Logic for rejected expense
}

// Get the full history
$events = $expense->latestWorkflowInstance()->events;
```

Configuration
-------------

[](#configuration)

The `config/approval-workflow.php` file allows you to customize:

- `user_model`: The model used for approvers.
- `manager_id_column`: The column on the User model pointing to their manager.
- `team_enabled`: Enable/disable team scoping.
- `fail_if_no_assignees`: Whether to throw an exception if no users are found for a step.

Testing
-------

[](#testing)

Run the tests using Pest:

```
vendor/bin/pest
```

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance74

Regular maintenance activity

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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 ~8 days

Total

3

Last Release

155d ago

Major Versions

0.0.1 → 1.0.02026-01-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/764935335a012f6477a36e9bf81144d2c887becfbd0dea300426a27f7677ab93?d=identicon)[putheakhem](/maintainers/putheakhem)

---

Top Contributors

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

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/putheakhem-approval-workflow/health.svg)

```
[![Health](https://phpackages.com/badges/putheakhem-approval-workflow/health.svg)](https://phpackages.com/packages/putheakhem-approval-workflow)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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