PHPackages                             ringlesoft/laravel-process-approval - 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. [Templating &amp; Views](/categories/templating)
4. /
5. ringlesoft/laravel-process-approval

ActiveLaravel-package[Templating &amp; Views](/categories/templating)

ringlesoft/laravel-process-approval
===================================

A package to handle process approval flow in a laravel application.

1.1.4(5mo ago)54126.1k↓28.3%56[2 issues](https://github.com/ringlesoft/laravel-process-approval/issues)4MITPHPPHP &gt;=8.1

Since Sep 28Pushed 5mo ago4 watchersCompare

[ Source](https://github.com/ringlesoft/laravel-process-approval)[ Packagist](https://packagist.org/packages/ringlesoft/laravel-process-approval)[ Docs](https://ringlesoft.com/packages/laravel-process-approval)[ RSS](/packages/ringlesoft-laravel-process-approval/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (21)Used By (4)

Laravel Process Approval
========================

[](#laravel-process-approval)

[![Latest Version on Packagist](https://camo.githubusercontent.com/de059943b2ae21394c5f0673403257a1453998cc0d513f63a2a96da880c9757e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696e676c65736f66742f6c61726176656c2d70726f636573732d617070726f76616c2e737667)](https://packagist.org/packages/ringlesoft/laravel-process-approval)[![Total Downloads](https://camo.githubusercontent.com/2a4206893d30be843c1449d5399b5679abb7d7907f24b01b7dfa571388b75d1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72696e676c65736f66742f6c61726176656c2d70726f636573732d617070726f76616c2e737667)](https://packagist.org/packages/ringlesoft/laravel-process-approval)[![PHP Version Require](https://camo.githubusercontent.com/55bc2b4e7aa071f2e20200374e67d5479cf65b1a52463b5f8f69565895585071/68747470733a2f2f706f7365722e707567782e6f72672f72696e676c65736f66742f6c61726176656c2d70726f636573732d617070726f76616c2f726571756972652f706870)](https://packagist.org/ringlesoft/laravel-process-approval)[![Dependents](https://camo.githubusercontent.com/4dc9efd142aae15b04c67f839f9c01408ea3ecc9c625d694b3ccfb673cd7617e/68747470733a2f2f706f7365722e707567782e6f72672f72696e676c65736f66742f6c61726176656c2d70726f636573732d617070726f76616c2f646570656e64656e7473)](https://packagist.org/packages/ringlesoft/laravel-process-approval)

---

Introduction
------------

[](#introduction)

This package enables multi-level approval workflows for Eloquent models in your Laravel application. If you have models that require review and approval from multiple approvers before execution, this package provides a flexible approval process to meet that need.

> Laravel 10.0 or later

The package relies on an existing `Role` management. This can be a custom role management or another package such as Spatie's `laravel permissions`.

[![Approvals Screenshot](https://camo.githubusercontent.com/2cafe3f30ebb75b2d5021d5d24b1d147f8414d877387b1b78f19393baa082370/68747470733a2f2f72696e676c65736f66742e636f6d2f696d616765732f7061636b616765732f617070726f76616c73322e706e67)](https://camo.githubusercontent.com/2cafe3f30ebb75b2d5021d5d24b1d147f8414d877387b1b78f19393baa082370/68747470733a2f2f72696e676c65736f66742e636f6d2f696d616765732f7061636b616765732f617070726f76616c73322e706e67)

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

[](#installation)

#### 1. Install Using composer:

[](#1-install-using-composer)

```
composer require ringlesoft/laravel-process-approval
```

#### 2. Publish Files (Optional)

[](#2-publish-files-optional)

This package provides publishable files that include configuration, migrations and views. You can publish these files using the following command:

```
php artisan vendor:publish --provider="RingleSoft\LaravelProcessApproval\LaravelProcessApprovalServiceProvider"
```

You can publish specific files by providing the `--tag` option within the publish command. Available options are `approvals-migrations`, `approvals-migrations-uuids`, `approvals-config`, `approvals-views`, `approvals-translations`.
 For example:

```
php artisan vendor:publish --provider="RingleSoft\LaravelProcessApproval\LaravelProcessApprovalServiceProvider" --tag="approvals-migrations"
```

> **Note:** If you run `php artisan process-approval:install`, it will publish the selected migration set for you (bigint by default, UUIDs with `--uuids`).

#### UUID Support (Optional)

[](#uuid-support-optional)

This package supports UUID primary keys for all package tables and UUID-based polymorphic relations.

If you want to use UUIDs, it is recommended to use the `install` command (this publishes the correct migrations and updates the published config):

```
php artisan process-approval:install --uuids
```

If you need to overwrite already published files, you can pass `--force`:

```
php artisan process-approval:install --uuids --force
```

If you prefer to publish migrations manually, a UUID migration tag is also available:

```
php artisan vendor:publish --provider="RingleSoft\LaravelProcessApproval\LaravelProcessApprovalServiceProvider" --tag="approvals-migrations-uuids"
```

> **Note**: If you manually publish migrations, make sure you set `load_migrations` in the config file to `false` to avoid running migrations twice. Running `process-approval:install` will set this variable to `false` for you.

#### 3. Run migration:

[](#3-run-migration)

The package comes with four migration files. Run artisan migrate command before you start using the package.

```
php artisan migrate
```

#### 4. Create Approval flows and Steps

[](#4-create-approval-flows-and-steps)

The package relies on Approval flows and steps on your default database. This is to enable multiple approval flows within the system. You can implement your own way of creating and managing the flows. However, there are available command-line functions to help you get started easily.

##### i. Creating a new flow

[](#i-creating-a-new-flow)

To create a new flow, Run the following command on your terminal.

```
 php artisan process-approval:flow add FundRequest
```

#### ii. Creating a step for the flow

[](#ii-creating-a-step-for-the-flow)

```
php artisan process-approval:step add
```

This will show a list of available Flows. Select the flow yow want to add steps to and then select the role and approval action.

#### iii. Deleting a flow

[](#iii-deleting-a-flow)

```
php artisan process-approval:flow remove
```

This will show a list of available flows. Select the step you want to delete and hit enter.

#### iv. Deleting a step

[](#iv-deleting-a-step)

```
php artisan process-approval:step remove
```

This will show a list of available steps. Select the step you want to delete and hit enter.

#### v. Listing all flows

[](#v-listing-all-flows)

```
php artisan process-approval:flow list
```

This will show a list of all available flows and steps

Usage
-----

[](#usage)

#### 1. Implement `ApprovableModel` on your approvable model

[](#1-implement-approvablemodel-on-your-approvable-model)

```
class FundRequest extends Model implements ApprovableModel
{

   // Your model content

}
```

#### 2. Apply the `Approvable` trait to the model

[](#2-apply-the--approvable-trait-to-the-model)

```
class FundRequest extends Model implements ApprovableModel
{
    use \RingleSoft\LaravelProcessApproval\Traits\Approvable;
   // Your model content

}
```

#### 3. Implement the `onApprovalCompleted()` method.

[](#3-implement-the-onapprovalcompleted-method)

This package relies on one callback method in your model to commit the last approval and mark the approval process as completed. You should implement this method and return `true` to finalize the approval or `false` to roll back the last approval. This is useful in the case of performing specific tasks when the approval procedure is completed.

```
class FundRequest extends Model implements ApprovableModel
{
    use \RingleSoft\LaravelProcessApproval\Traits\Approvable;
   // Your model content

    public function onApprovalCompleted(ProcessApproval $approval): bool
    {
        // Write logic to be executed when the approval process is completed
        return true;
    }
}
```

#### 4. Place the `` component on the show page of your model and provide the model instance using the `model` parameter.

[](#4-place-the-x-ringlesoft-approval-actions-component-on-the-show-page-of-your-model-and-provide-the-model-instance-using-the-model-parameter)

```

```

Currently, the UI is implemented using `tailwind`, `bootstrap` or vanilla `css`. You can switch between the frameworks by modifying the `css_library` setting in the configuration file. Additionally, you have the option to publish the views and customize them to meet your specific requirements.

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

[](#configuration)

You can publish the configuration file of this package, `process_approval.php`, and modify the variables to align with your specific requirements. If you wish to publish the files, use the following command:

```
php artisan vendor:publish --provider="RingleSoft\LaravelProcessApproval\LaravelProcessApprovalServiceProvider" --tag="approvals-config"
```

### Configurable parameters

[](#configurable-parameters)

- `roles_model` - Specify the full class name of the model related to roles table. (default is Spatie's laravel-permissions (`Spatie\Permissions\Models\Role`))
- `users_model` - Specify the model that represents the authenticated users. (default is `App\Models\User`).
- `models_path` - Specify the default namespace for models in your application. (default is `App\Models`).
- `approval_controller_middlewares` - Specify any middlewares you want to apply to the ApprovalController. (Normally it should be `['auth']`).
- `css_library` - Specify the css library for styling the UI component (bootstrap/tailwind). (default is `Tailwind CSS`).
- `multi_tenancy_field` - Specify the multi-tenancy field in the users table. (default is `tenant_id`)
- `use_uuids` - Enable UUID support for all package tables and UUID-based polymorphic relations (recommended for fresh installs).
- `load_migrations` - If true, the package auto-loads vendor migrations. If you publish migrations into your app, make sure set this to `false`.

### Model Submitting

[](#model-submitting)

By default, the model becomes ready for approval when it is marked as "submitted". This provides the opportunity for editing and other actions on the model before the approval procedure commences. This feature is particularly useful if you wish to keep newly created models hidden from approvers until the creator submits them.

If you want the model to be auto-submitted upon creation, you can add the following property to the model:

```
public bool $autoSubmit = true;
```

Or define the method `enableAutoSubmit(): bool` in your model **(Recommended)**.

```
public function enableAutoSubmit(): bool
{
    // Your logic here
    return true;
}
```

Otherwise, the package will show a submit button on the show page of the model to enable the creator to submit the model.

### Bypassing Approval Process

[](#bypassing-approval-process)

If you want to bypass the approval process for a particular model instance, you can define the method `bypassApprovalProcess(): bool` in your model and return `true`.

```
public function bypassApprovalProcess(): bool
{
    // Your logic here
    return true;
}
```

### Pausing Approval process

[](#pausing-approval-process)

Sometimes you may wish to interrupt the approval procedure by adding your own actions before continuing with approvals. You can pause approvals by adding a `pauseApprovals(): mixed` method to your Approvable Model.

```
public function pauseApprovals() {
    // Your logic here
    return true;
}
```

If this method returns true, the approval actions UI will disappear, and you will be able to implement your other logics. If the method returns `'ONLY_ACTIONS'` the existing approvals will be displayed but approval actions will be hidden and disabled.

### Approval Signatures

[](#approval-signatures)

If you want to use signatures for users, add the `getSignature()` method to your User model and make it return the signature of the user as image url.

```
Class User extends Model {
    ...

    public function getSignature(){
        return $this->signature_path; // Return the path to user's signature
    }
}
```

If not specified, the package will display `check` icon for approval and `times` icon for rejection.

### Approval Summary

[](#approval-summary)

If you want to display a summary of the approval process (normally when listing the models) you can use the `` component. This component returns html code with icons representing every approval step: `check` icon representing `Approved`, `times`icon representing `Rejected` or `Discarded` and `exclamation` icon representing `Pending`.

Events
------

[](#events)

The package dispatches events during different stages of the approval workflow to allow hooking into the process.

- `ProcessSubmittedEvent` - Dispatched when a new approvable model is submitted.
- `ProcessApprovedEvent` - Dispatched when an approvable model is approved by an approver.
- `ProcessRejectedEvent` - Dispatched when an approvable model is rejected by an approver.
- `ProcessReturnedEvent` - Dispatched when an approvable model is returned back to the previous step by an approver.
- `ProcessDiscardedEvent` - Dispatched when an approvable model is discarded by an approver.
- `ProcessApprovalCompletedEvent` - Dispatched when the full approval workflow is completed (approved or discarded).
- `ApprovalNotificationEvent` - Dispatched during approval actions with a notification message about what happened.

### Showing Notifications

[](#showing-notifications)

To display approval notifications, subscribe to the `ApprovalNotificationEvent` event.

#### 1. Create a Listener:

[](#1-create-a-listener)

Generate a listener for the event using artisan command:

```
php artisan make:listener ApprovalNotificationListener --event=\\RingleSoft\\LaravelProcessApproval\\Events\\ApprovalNotificationEvent
```

#### 2. Implement Listener Logic:

[](#2-implement-listener-logic)

Inside the generated ApprovalNotificationListener class, implement the logic within the `handle()` method. This method will execute whenever the ApprovalNotificationEvent event is triggered. Customize the notification content and delivery method as per your application's requirements.

Example listener implementation:

```
class ApprovalNotificationListener
{
    ...
    /**
     * Handle the event.
     */
    public function handle(ApprovalNotificationEvent $event): void
    {
        session()->flash('success', $event->message);
    }
}
```

#### 3. Register Listener:

[](#3-register-listener)

Register the listener in your `EventServiceProvider` class to link the `ApprovalNotificationEvent` event with your `ApprovalNotificationListener`:

```
protected $listen = [
    ApprovalNotificationEvent::class => [
        ApprovalNotificationListener::class,
    ],
];
```

Use your own approach to display notification from `session()`

### Notifying Approvers

[](#notifying-approvers)

To notify approvers when a document is awaiting their approval, you can subscribe to the `ProcessSubmittedEvent` and `ProcessApprovedEvent` events and send notifications to them.

Here is an example of how to send notifications to the next approvers within the `ProcessSubmittedListener` listener:

```
    public function handle(ProcessSubmittedEvent $event): void
    {
        $nextApprovers = $event->approvable->getNextApprovers();
        foreach ($nextApprovers as $nextApprover) {
            $nextApprover->notify(new AwaitingApprovalNotification($event->approvable));
        }
    }
```

Helper Methods
--------------

[](#helper-methods)

This package adds multiple helper methods to the approvable models. These include:

### Filters

[](#filters)

- `approved()` \[Static\]: This returns a builder that filters the model entries that are only approved ( returns `Illuminate\Database\Eloquent\Builder`) Example:

    ```
        FundRequest::approved()->get();
    ```
- `rejected()` \[Static\]:This returns a builder that filters the model entries that are only rejected ( returns `Illuminate\Database\Eloquent\Builder`) Example:

    ```
        FundRequest::rejected()->get();
    ```
- `discarded()` \[Static\]:This returns a builder that filters the model entries that are only discarded ( returns `Illuminate\Database\Eloquent\Builder`) Example:

    ```
        FundRequest::discarded()->get();
    ```
- `returned()` \[Static\]:This returns a builder that filters the model entries that are only returned ( returns `Illuminate\Database\Eloquent\Builder`) Example:

    ```
        FundRequest::returned()->get();
    ```
- `submitted()` \[Static\]:This returns a builder that filters the model entries that are only submitted ( returns `Illuminate\Database\Eloquent\Builder`) Example:

    ```
        FundRequest::submitted()->get();
    ```

### Actions

[](#actions)

- `submit([user: Authenticatable|null = null]): bool|RedirectResponse|ProcessApproval`: Submits the model
- `approve([comment = null], [user: Authenticatable|null = null]): bool|RedirectResponse|ProcessApproval`: Approves the model
- `reject([comment = null], [user: Authenticatable|null = null]): bool|ProcessApproval`: Rejects the model
- `return([comment = null], [user: Authenticatable|null = null]): bool|ProcessApproval`: Returns the model to the previous step
- `discard([comment = null], [user: Authenticatable|null = null]): bool|ProcessApproval`: Discards the model

### Misc

[](#misc)

- `isApprovalCompleted(): bool`: Checks if the approval process for the model is completed
- `isSubmitted(): bool`: Checks if the model has been submitted
- `isRejected(): bool`: Checks if the model has been rejected
- `isDiscarded(): bool`: Checks if the model has been discarded
- `isReturned(): bool`: Checks if the model has been returned back to the previous step
- `nextApprovalStep(): null|ProcessApprovalFlowStep`: Returns the next approval step for the model
- `previousApprovalStep(): null|ProcessApprovalFlowStep`: Returns the previous approval step for the model
- `canBeApprovedBy(user: Authenticatable|null): bool|null`: Checks if the model can currently be approved by the specified user.
- `onApprovalCompleted(approval: ProcessApproval): bool`: A callback method to be called when the approval process is completed. This method must be implemented and must return true for the last approval to be successful. Otherwise, the last approval will be rolled back.
- `getNextApprovers(): Collection`: Returns a list of users that are capable of approving the model at its current step.

#### Relations

[](#relations)

- `approvals(): morphMany` - Returns all approvals of the model
- `lastApproval(): morphOne` - Returns the last approval (`Models\ProcessApproval`) of the model
- `approvalStatus(): morphOne` - Returns the status object (`Models\ProcessApprovalStatus`) of the model

Seeding
-------

[](#seeding)

If you want to seed your approval flows to the database, this package provides a static method `makeApprovable(): bool` to create a new approval flow for a model. This method can be used to seed the database with the necessary approval flows and steps for a model.

The method accepts two parameters:

- `$steps`: An array defining the roles to be used as approval steps.
- `$name`: (optional) The name of the approval flow.

#### Basic usage:

[](#basic-usage)

When the first parameter is a flat array of integers, the method creates a new approval flow with the array items as `role_id` and sets `ApprovalTypeEnum::APPROVE` as the default action for each step.

```
    FundRequest::makeApprovable([1,2,3]);
```

#### Advanced usage:

[](#advanced-usage)

When the first parameter is an associative array of `[int => ApprovalTypeEnum, ...]`, the method creates a new approval flow with the array keys (`int`) as `role_id` and the values (`ApprovalTypeEnum`) as the corresponding action.

```
    FundRequest::makeApprovable([
        1 => ApprovalTypeEnum::APPROVE,
        3 => ApprovalTypeEnum::CHECK
    ]);
```

#### Complex usage:

[](#complex-usage)

When the first parameter is an array of arrays, the method creates a new approval flow with steps that accepts `[role_id => int, action => ApprovalTypeEnum]` from the sub-arrays.

```
    FundRequest::makeApprovable([
                [
                    'role_id' => 2,
                    'action' => ApprovalTypeEnum::CHECK->value
                ],
                [
                    'role_id' => 1,
                    'action' => ApprovalTypeEnum::CHECK->value
                ],
                [
                    'role_id' => 1,
                    'action' => ApprovalTypeEnum::APPROVE->value
                ]
            ]
        );
```

This option enables you to create a flow with multiple steps for the same role, each step having a different action or occurrence.

> **Note:** If you are using the Laravel's DatabaseSeeder, make sure to remove the `use WithoutModelEvents;` to be able to use the `makeApprovable()` method.

Multi-Tenancy
-------------

[](#multi-tenancy)

This package supports multi-tenancy by configuring a column in the users table. You can specify the column name using the `multi_tenancy_field` configuration option. When the logged-in user is has the `tenant_id` field set, the package will use that value to filter the approval steps. With this you can have one approval flow with different steps for different tenants.

Testing
-------

[](#testing)

To test this package, switch to the `tests` branch and run `composer install` to install the dependencies and `vendor/bin/testbench package:test` to run the tests.

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

[](#contributing)

You are welcome to contribute to this package. Please fork the repository and create a pull request.

License
-------

[](#license)

Laravel Process Approval is open-source software released under the MIT License.

Support
-------

[](#support)

- [Buy me a Coffee](https://www.buymeacoffee.com/ringunger)
- [Github Sponsors](https://github.com/sponsors/ringlesoft)

Contacts
--------

[](#contacts)

Follow me on [X](https://x.com/ringunger): [@ringunger](https://x.com/ringunger)
Email me: [](mailto:ringunger@gmail.com)
Website: [https://ringlesoft.com](https://ringlesoft.com/packages/laravel-process-approval)

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance73

Regular maintenance activity

Popularity50

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 97.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 ~50 days

Recently: every ~65 days

Total

17

Last Release

150d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e6e20f0cc6e0f58ef2b8460f08d3d4dfe10d69aaaf352a1b5a201f13eb236d4?d=identicon)[ringunger](/maintainers/ringunger)

---

Top Contributors

[![ringunger](https://avatars.githubusercontent.com/u/6137527?v=4)](https://github.com/ringunger "ringunger (229 commits)")[![tonypartridge](https://avatars.githubusercontent.com/u/1400982?v=4)](https://github.com/tonypartridge "tonypartridge (2 commits)")[![kraziegent](https://avatars.githubusercontent.com/u/2316853?v=4)](https://github.com/kraziegent "kraziegent (1 commits)")[![kwumr](https://avatars.githubusercontent.com/u/47462678?v=4)](https://github.com/kwumr "kwumr (1 commits)")[![ShojibFlamon](https://avatars.githubusercontent.com/u/5617542?v=4)](https://github.com/ShojibFlamon "ShojibFlamon (1 commits)")

---

Tags

approval-processapprovalsbladelaravellaravelflowapprovalprocedureapproveringlesoft

### Embed Badge

![Health badge](/badges/ringlesoft-laravel-process-approval/health.svg)

```
[![Health](https://phpackages.com/badges/ringlesoft-laravel-process-approval/health.svg)](https://phpackages.com/packages/ringlesoft-laravel-process-approval)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[silber/bouncer

Eloquent roles and abilities.

3.6k4.4M25](/packages/silber-bouncer)[laravelista/comments

Comments for Laravel.

744192.4k1](/packages/laravelista-comments)[hasinhayder/tyro-login

Tyro Login - Beautiful, customizable authentication views for Laravel 12 &amp; 13

2362.2k2](/packages/hasinhayder-tyro-login)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)

PHPackages © 2026

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