Download the PHP package ringlesoft/laravel-process-approval without Composer

On this page you can find all versions of the php package ringlesoft/laravel-process-approval. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-process-approval

Laravel Process Approval

Latest Version on Packagist Total Downloads PHP Version Require Dependents


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

Installation

1. Install Using composer:

2. Publish Files (Optional)

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

You can publish specific files by providing the option within the publish command. Available options are , , , .
For example:

3. Run migration:

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

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

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

ii. Creating a step for the flow

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

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

iv. Deleting a step

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

v. Listing all flows

This will show a list of all available flows and steps

Usage

1. Implement AprovableModel to your approvable model

2. Apply the Approvable trait to the model

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.

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 or bootstrap. Support for vanilla CSS and JS will be available soon. You can switch between the two 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

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:

Configurable parameters

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:

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

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.

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

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.

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

Approval Summary

If you want to display a summary of the approval process (normally when listing the models) you can use the <x-ringlesoft-approval-status-summary> 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

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

Showing Notifications

To display approval notifications, subscribe to the ApprovalNotificationEvent event.

1. Create a Listener:

Generate a listener for the event using artisan command:

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:

3. Register Listener:

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

Use your own approach to display notification from session()

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:

Helper Methods

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

Filters

Actions

Misc

Relations

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:

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.

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.

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.

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

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

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

I'll let you know when you can contribute 😜.

License

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

Support

Contacts

Follow me on X: @ringunger
Email me: [email protected]
Website: https://ringlesoft.com


All versions of laravel-process-approval with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/auth Version ^10.0|^11.0
illuminate/broadcasting Version ^10.7|^11.0
illuminate/database Version ^10.0|^11.0
illuminate/routing Version ^10.24|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ringlesoft/laravel-process-approval contains the following files

Loading the files please wait ....