定制 moffhub/maker-checker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

moffhub/maker-checker

最新稳定版本:v0.0.13

Composer 安装命令:

composer create-project moffhub/maker-checker

包简介

A laravel package to help manage with maker checker tight requirement

README 文档

README

MakerChecker is a package that provides a simple way to implement the Maker-Checker pattern in your Laravel application.

Installation

You can install the package via composer:

composer require moffhub/maker-checker

This package depends on the sourcetoad\enhanced-resources which you can install via composer:

composer require sourcetoad\enhanced-resources

You can publish the config file with:

php artisan vendor:publish --provider="Moffhub\MakerChecker\MakerCheckerServiceProvider" --tag="config"

This is the contents of the published config file:

Usage

First, you need to add the ChecksRequests trait to the model you want to check against for roles and permissions typically the User Model.

use Moffhub\MakerChecker\Traits\ChecksRequests; class Post extends Model { use ChecksRequests; }

Then, you can use the makerChecker method to create a new record.

 if (auth()->user()->requiresApproval('create', Post::class)) { $approvalRequest = MakerChecker::request() ->toExecute( $approvableActionClass, (array) $data, ) ->madeBy(auth()->user()) ->description('Create Posts') ->save(); return MakerCheckerResource::make($approvalRequest) ->format(MakerCheckerResource::SIMPLE) ->response() ->setStatusCode(Response::HTTP_MULTI_STATUS); }

Approvable actions

This library supports create, delete, update and execute actions. You can create your own actions by extending the ApprovableAction class.

This is configured by either calling

for execute Additionally you can pass an array of roles that can approve the request and the number of approvals required for the request to be approved by each role

MakerChecker::request()->toExecute( $approvableActionClass, (array) $data, [ 'admin'=> 2, 'client' => 3, ], )

or for create

MakerChecker::request()->toCreate( $createActionClass, (array) $data, )

or for update

MakerChecker::request()->toUpdate( $updateActionClass, (array) $data, )

or for delete

MakerChecker::request()->toDelete( $deleteActionClass, (array) $data, )

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固