afiqiqmal / approval-laravel
approval-laravel
Fund package maintenance!
afiqiqmal
Installs: 3 008
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 2
Open Issues: 1
Requires
- php: ^7.4|^8.0
- illuminate/contracts: ^6 || ^7 || ^8 || ^9 || ^10 || ^11
- illuminate/support: ^6 || ^7 || ^8 || ^9 || ^10 || ^11
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3
README
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.