定制 robinhoo1973/laravel-database-trigger-5.8 二次开发

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

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

robinhoo1973/laravel-database-trigger-5.8

Composer 安装命令:

composer require robinhoo1973/laravel-database-trigger-5.8

包简介

A package to add database trigger to laravel migrations

README 文档

README

Software License Build Status StyleCI

Laravel Database Trigger provides a way to add database trigger to laravel migrations just like you would with database table. A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. Read more about triggers here.

Installation

Laravel Database Trigger requires at least PHP 7.1. This particular version supports laravel at least v5.5. The package currently supports MySQL only.

To get the latest version, simply require the package using Composer:

$ composer require ntimyeboah/laravel-database-trigger

Once installed, if you are not using automatic package discovery, then you need to register the TopviewDigital\LaravelDatabaseTrigger\TriggerServiceProvider service provider in your config/app.php.

Usage

Create a trigger migration file using the make:trigger artisan command. The command requires the name of the trigger, name of the event object table, action timing and the event that activates the trigger.

$ php artisan make:trigger after_users_update

Event object table

The event object table is the name of the table the trigger is associated with.

Action timing

The activation time for the trigger. Possible values are after and before.

after - Process action after the change is made on the event object table.

before - Process action prior to the change is made on the event object table.

Event

The event to activate trigger. A trigger event can be insert, update and delete.

insert - Activate trigger when an insert operation is performed on the event object table.

update - Activate trigger when an update operation is performed on the event object table.

delete - Activate trigger when a delete operation is performed on the event object table.

The following trigger migration file will be generated for a trigger that uses after_users_update as a name, users as event object table name, after as action timing and update as event.

use Illuminate\Database\Migrations\Migration;
use TopviewDigital\LaravelDatabaseTrigger\TriggerFacade as Schema;

class CreateAfterUsersUpdateTrigger extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('after_users_update')
            ->on('users')
            ->statement(function() {
                return '//...';
            })
            ->after()
            ->update();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users.after_users_update');
    }
}

Return the trigger statement from the closure of the statement method.

The following is an example trigger migration to insert into the users_audit table after updating a user row.

...

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('after_users_update')
            ->on('users')
            ->statement(function() {
                return 'insert into `users_audit` (`name`, `email`) values (old.name, old.email);';
            })
            ->after()
            ->update();
    }

...

Testing

Run the tests with:

$ composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover a security vulnerability within this package, please send an e-mail to Ntim Yeboah at ntimobedyeboah@gmail.com. All security vulnerabilities will be promptly addressed.

License

Laravel Database Trigger is licensed under The MIT License (MIT).

robinhoo1973/laravel-database-trigger-5.8 适用场景与选型建议

robinhoo1973/laravel-database-trigger-5.8 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 85 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「trigger」 「NtimYeboah」 「laravel-database-trigger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 robinhoo1973/laravel-database-trigger-5.8 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-25