afiqiqmal/approval-laravel

approval-laravel

1.6.0 2024-01-12 01:04 UTC

This package is auto-updated.

Last update: 2024-04-12 01:36:07 UTC


README

Latest Version on Packagist Total Downloads Donate

Installation

You can install the package via composer:

composer require afiqiqmal/approval-laravel

You can publish and run the migrations with:

php artisan vendor:publish --provider="Afiqiqmal\Approval\ApprovalServiceProvider" --tag="migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="Afiqiqmal\Approval\ApprovalServiceProvider" --tag="config"

Usage

Add RequireApproval trait to the model

class Entity extends Model
{
    use RequireApproval;

    //plenty of public function can be customize
}

Add HasApprovable trait to the User Model

class User extends Authenticable
{
    use HasApprovable;
    //...
    //...
}

Query

Include all items including not approve

Model::getQuery()->includeNotApprove()->get(); 

List all items with not approve

Model::getQuery()->onlyNotApprove()->get(); 

Approve and Reject Item

$item = Model::first();
$item->approve()->approve($remarks); // optional remarks
$item->approve()->reject($remarks); // optional remarks

Vice versa to get the approval model

$approval = Approval::first();

$approval->approvable; // Get model

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

68747470733a2f2f692e696d6775722e636f6d2f5932677172326a2e706e67