prodevel/laravel-simple-approvals

Approval workflows for a laravel application.

0.2.1 2021-03-13 12:42 UTC

This package is auto-updated.

Last update: 2024-04-13 20:24:03 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.