prodevel / laravel-simple-approvals
Approval workflows for a laravel application.
0.2.1
2021-03-13 12:42 UTC
Requires
- php: ^7.3|^8.0
- illuminate/collections: ^7.0||^8.0
- illuminate/database: ^7.0||^8.0
- illuminate/support: ^7.0||^8.0
- zerodahero/laravel-workflow: ^3.2
Requires (Dev)
- mockery/mockery: ^1.4.2
- nunomaduro/collision: ^5.0
- phpunit/phpunit: ^9.3.3
This package is auto-updated.
Last update: 2024-11-13 21:42:55 UTC
README
This is a simple package built on Symfony workflow Laravel implementation by brexis. It allows you to have simple approval workflows that can be recorded in the database.
Use this to approve things like:
- Transfers
- Data changes
- Or anything that you want to attach an approval to.
It is flexible and agnostic and can be used with any Eloquent model.
Usage
From your model, implement Approvable
contract for example
<?php namespace MyNamespace; use Illuminate\Database\Eloquent\Model; use Prodevel\Laravel\Workflow\Traits\ApprovableTrait; use Prodevel\Laravel\Workflow\Contracts\Approvable; class DemoModel extends Model implements Approvable { use ApprovableTrait; }
Creating an approval request
<?php class DemoController { public function requestApprovalDemo() { $model = new ModelThatImplementsApprovable; $model->requestApproval(Auth::user()); } }
Approving and rejecting workflow
<?php class DemoController { public function requestApprovalDemo() { $model = ExistingWorkflowThatImplementsApprovable::first(); ; $model->currentApproval()->approve(Auth::user()); $model->currentApproval()->reject(Auth::user()); } }
Security Vulnerabilities
If you discover a security vulnerability within this package, please send an e-mail to Promise via promise@prodevel.co.uk. All security vulnerabilities will be promptly addressed.
License
This package is open-sourced software licensed under the MIT license.