承接 traknpay/laravel-eloquent-approval 相关项目开发

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

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

traknpay/laravel-eloquent-approval

Composer 安装命令:

composer require traknpay/laravel-eloquent-approval

包简介

Approval Package For Laravel Eloquent Model

README 文档

README

Approval process for Laravel's Eloquent models.

How it works?

New entities are created in the 'approval' table as pending and then can become approved or rejected.

Install

$ composer require traknpay/laravel-eloquent-approval

Version Compatibility

Laravel Version Package Version
5.6.* ^1.0

Setup

Registering the service provider

By default the service provider is registered automatically by Laravel package discovery otherwise you need to register it in your config\app.php

TraknPay\EloquentApproval\ApprovalServiceProvider::class

Run the following commands to migrate the 'approval' table:

php artisan vendor:publish --provider='TraknPay\EloquentApproval\ApprovalServiceProvider'

php artisan migrate

Model

Add ApprovalTrait trait to the model and override the isApprover() function as per your need.

use Illuminate\Database\Eloquent\Model;
use TraknPay\EloquentApproval\ApprovalTrait;

class Entity extends Model
{
    use ApprovalTrait;
    
    public static function isApprover(): bool
    {
        return true;
    }
}

By default isApprover() is true and if you use this trait, it will not put the new entities in the approval table. You can override this functionality based on your need. If isApprover() function returns false then entities are added to approval table and mark the transaction as false. Hence, if 'isApprover()' returns false the model will not be persited to database instead added to 'approval' table for approval. For example, in this function you can check whether user has permission to approve or not.

##Approval Events

Following model events are dispatched before and after saving data into 'approval' table.

  1. sendingForApproval - before saving data into 'approval' table.
  2. sentForApproval - after saving data into 'approval' table.

Inspirations

I got some inspiration from mtvs/eloquent-approval package. Even though , I wrote my own package for my project purpose I got some insights on how to write my own package from this.

统计信息

  • 总下载量: 466
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固