定制 masterbroki/hookable 二次开发

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

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

masterbroki/hookable

最新稳定版本:v10.0.4

Composer 安装命令:

composer require masterbroki/hookable

包简介

Laravel Eloquent hooks system.

README 文档

README

GitHub Tests Action Status stable Downloads

This is a overhaul of the Hookable system from jarektkaczyk/hookable to support laravel 10 and make the system leaner.

Hooks system for the Eloquent ORM (Laravel 10.0).

Hooks are available for the following methods:

  • Model::getAttribute
  • Model::setAttribute
  • Model::save
  • Model::toArray
  • Model::replicate
  • Model::isDirty
  • Model::__isset
  • Model::__unset

and all methods available on the Illuminate\Database\Eloquent\Builder class.

Installation

Clone the repo or pull as composer dependency:

composer require masterbroki/hookable:~10.0

Usage

Use the hookable trait on the model:

class MyModel extends \Illuminate\Database\Eloquent\Model{
    use Sofa\Hookable\Hookable;
}

In order to register a hook, use the static method hook on the model:

MyModel::hook('myMethod', function($myParams){
    return "I want to select: " . implode(', ', $myParams);
});

And when the attribute is called:

$result = MyModel::select(["first", "second"]);

// $result will equal "I want to select: first, second"

Contribution

All contributions are welcome, PRs must be tested.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-21