scito/eloquent-webhooks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

scito/eloquent-webhooks

最新稳定版本:1.01

Composer 安装命令:

composer require scito/eloquent-webhooks

包简介

Fire webhooks based on eloquent events

README 文档

README

Dispatch http requests on model events with zero configuration.

Installation

Install the package.

composer require scito/eloquent-webhooks

Run the migration to create eloquent_webhooks table.

php artisan migrate

If you don't have auto discovery add the service provider in config/app.php.

'providers' = [
    Scito\EloquentWebhooks\Providers\WebhookServiceProvider::class,

    // ...
];

Configuration

Add the Webhooks trait in your model. Out of the box all published properties of your model will be available during the evaluation of the shortcodes in your webhook url.

use Illuminate\Database\Eloquent\Model;
use Scito\EloquentWebhooks\Traits\Webhooks;

class Post extends Model
{
    use Webhooks;

    // ...
}

The shotcodes in a webhook will be evaluated against $model->toArray().

You can customize the data to evaluate by adding webhookData() in your model.

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Scito\EloquentWebhooks\Models\EloquentWebhook;
use Scito\EloquentWebhooks\Traits\Webhooks;

class Post extends Model
{
    use Webhooks;

    public function author(): BelongsTo
    {
        return $this->belongsTo(Author::class);
    }

    public function webhookData(EloquentWebhook $webhook): array
    {
        return [
            'title' => $this->name,
            'author' => $this->author->name,
        ];
    }

    // ...
}

Creating webhooks

use Scito\EloquentWebhooks\Models\EloquentWebhook;

EloquentWebhook::create([
    'model' => Post::class,
    'event' => 'created',
    'status' => 'active',
    'method' => 'get',
    'link' => 'https://example.com?name={title}&author={author}',
]);

You can also dispatch post requests, webhookData() / $model->toArray() will be sent as request payload.

use Scito\EloquentWebhooks\Models\EloquentWebhook;

EloquentWebhook::create([
    'model' => Post::class,
    'event' => 'created',
    'status' => 'active',
    'method' => 'post',
    'link' => 'https://example.com',
]);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固