承接 putheakhem/approval-workflow 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

putheakhem/approval-workflow

Composer 安装命令:

composer require putheakhem/approval-workflow

包简介

Flexible approval workflow engine for Laravel (approval chain, steps, parallel approvals, audit trail).

README 文档

README

Tests Latest Stable Version License

🇰🇭 Stand with Cambodia • កម្ពុជា

🕊️ Cambodia Needs Peace 🕊️

We stand in solidarity with our brave soldiers defending Cambodia's sovereignty and territorial integrity. Our hearts are with those protecting our homeland during these challenging times. We call upon the international community to support peaceful resolution and respect for Cambodia's borders.

🙏 កម្ពុជាត្រូវការសន្តិភាព • Together we stand for peace and sovereignty

---

Approval Workflow for Laravel

A flexible, database-driven approval workflow engine for Laravel applications. It supports multi-step approval chains, parallel approvals, SLA monitoring, and dynamic assignment.

Features

  • Multiple Workflow Versions: Define and evolve workflows over time without breaking existing instances.
  • Dynamic Assignment: Assign tasks to users, roles (Spatie Permission integration), or managers.
  • Flexible Modes: Support for 'any' (one person approves) or 'all' (consensus required) modes.
  • SLA Monitoring: Built-in support for task deadlines and breach recording.
  • Delegation: Automatic redirection of tasks based on user availability (vacation/out-of-office).
  • Audit Trail: Detailed event logging (started, assigned, acted, breached, completed) for every action.
  • Conditional Transitions: Override default flow based on actions (approve/reject/changes_requested).

Documentation

For detailed documentation, please visit https://laravel-approval-workflow.netlify.app

Installation

Add the package to your composer.json or install it via composer:

composer require putheakhem/approval-workflow

Detailed Examples

For practical code snippets of each feature, check out the EXAMPLES.md file.

Setup

  1. Publish Configuration & Migrations:
php artisan vendor:publish --provider="PutheaKhem\ApprovalWorkflow\ApprovalWorkflowServiceProvider"
  1. Run Migrations:
php artisan migrate
  1. Configure the User Model: Ensure config/approval-workflow.php points to your User model (usually App\Models\User).

  2. Add the Trait: Add the HasWorkflow trait to any Eloquent model that requires an approval process:

use PutheaKhem\ApprovalWorkflow\Concerns\HasWorkflow;

class ExpenseClaim extends Model
{
    use HasWorkflow;
}

Usage

1. Defining a Workflow

Workflows are stored in the database. You typically create them via a seeder or an admin UI.

use PutheaKhem\ApprovalWorkflow\Models\Workflow;
use PutheaKhem\ApprovalWorkflow\Models\WorkflowVersion;

$workflow = Workflow::create(['key' => 'expense-approval', 'name' => 'Expense Approval']);

WorkflowVersion::create([
    'workflow_id' => $workflow->id,
    'version' => 1,
    'published_at' => now(),
    'definition' => [
        'steps' => [
            ['key' => 'start', 'type' => 'start', 'next' => 'manager_step'],
            [
                'key' => 'manager_step',
                'name' => 'Manager Approval',
                'assignment' => ['type' => 'manager_of', 'field' => 'requester_id'],
                'next' => 'end'
            ],
            ['key' => 'end', 'type' => 'end'],
        ],
    ],
]);

2. Starting a Workflow

$expense = ExpenseClaim::create([...]);
$instance = $expense->startWorkflow('expense-approval', [
    'requester_id' => auth()->id(),
    'amount' => 500
]);

3. Approving / Rejecting

Tasks are created for each step. Approvers can act on these tasks.

use PutheaKhem\ApprovalWorkflow\Services\ApprovalService;

$service = app(ApprovalService::class);
$task = $instance->currentTasks()->first();

$service->approve($instance, $task->id, auth()->id(), 'Looks good!');

4. Checking Status

if ($expense->isApproved()) {
    // Logic for approved expense
}

if ($expense->isRejected()) {
    // Logic for rejected expense
}

// Get the full history
$events = $expense->latestWorkflowInstance()->events;

Configuration

The config/approval-workflow.php file allows you to customize:

  • user_model: The model used for approvers.
  • manager_id_column: The column on the User model pointing to their manager.
  • team_enabled: Enable/disable team scoping.
  • fail_if_no_assignees: Whether to throw an exception if no users are found for a step.

Testing

Run the tests using Pest:

vendor/bin/pest

License

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

putheakhem/approval-workflow 适用场景与选型建议

putheakhem/approval-workflow 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 5, 最近一次更新时间为 2026 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 putheakhem/approval-workflow 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 putheakhem/approval-workflow 我们能提供哪些服务?
定制开发 / 二次开发

基于 putheakhem/approval-workflow 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-13