httpfactory/approvals
Composer 安装命令:
composer require httpfactory/approvals
包简介
Approvals Package
README 文档
README
Approval System
The approval system package is an add-on package that allows seamless integration into laravel 5.7+
Installation
To install simply pull in the package to your laravel project
composer install httpfactory\approvals
After you have successfully installed it via composer, you will need to
register the package in your config\app.php file.
Add the following line to your service providers array :
Httpfactory\Approvals\ApprovalServiceProvider::class
Now you need to run the following command :
php artisan vendor:publish --provider=Httpfactory\Approvals\ApprovalServiceProvider
After registering the package, you will need to run migrations
Run The Migrations
you must run your migrations as follows
php artisan migrate
Events
You will need to add the following events to the app\Providers\EventServiceProvider.php
-
ApprovalRequest
Httpfactory\Approvals\Events\ApprovalRequest- Fires when someone sends an approval request.
-
ApprovalApproved
Httpfactory\Approvals\Events\ApprovalApproved- Fires when an "approver" approves the approval request.
-
ApprovalDeclined
Httpfactory\Approvals\Events\ApprovalDeclined- Fires when an "approver" declines the approval request.
-
ApprovalAwarded
Httpfactory\Approvals\Events\ApprovalAwarded- Fires when the approval configuration requirements are met and the approval is automatically awarded.
-
ApprovalDenied
Httpfactory\Approvals\Events\ApprovalDenied- Fires when the approval configuration requirements are met and the approval is automatically denied.
The Events should look something like the code below
//Begin the approval events
'Httpfactory\Approvals\Events\ApprovalRequest' => [
'Httpfactory\Approvals\Listeners\ApprovalRequest',
],
'Httpfactory\Approvals\Events\ApprovalApproved' => [
'Httpfactory\Approvals\Listeners\ApprovalApproved',
],
'Httpfactory\Approvals\Events\ApprovalDeclined' => [
'Httpfactory\Approvals\Listeners\ApprovalDeclined',
],
'Httpfactory\Approvals\Events\ApprovalAwarded' => [
'Httpfactory\Approvals\Listeners\ApprovalAwarded',
],
'Httpfactory\Approvals\Events\ApprovalDenied' => [
'Httpfactory\Approvals\Listeners\ApprovalDenied',
],
Usage
There are multiple types of approvals :
- Quick Approval ( 1 to 1 )
- Group Approval ( a group of users must approve/deny )
- MultiTier Approval ( multiple groups must approve/deny )
Quick Approval
Below is an example of a quick approval :
<?php
namespace Acme\SomeProject;
use Httpfactory\Approvals\QuickApproval;
use App\User;
class Someclass {
public function requestApproval(){
//Some user instance that is requesting the approval...
$user = User::find(1);
//If you have a Laravel Spark and are using "Teams"
//The User's currentTeam is going to be used as the Team Id association.
//Create a new Approval of certain type, then request the actual approval.
$approval = new QuickApproval($user);
$approval->name = 'Credit Card';
$approval->description = 'Requesting Permission to use the company credit card for something cool';
$approval->approvalsNeeded = 1;
$usersThatIneedApprovalFrom = User::where('id', '!=', 1)->get();
$approval->from($usersThatIneedApprovalFrom)->sendRequest();
}
}
In the example above, we are sending a request to a user for approval.
httpfactory/approvals 适用场景与选型建议
httpfactory/approvals 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 67 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 httpfactory/approvals 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 httpfactory/approvals 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 67
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-11-26