2016-10-11 6 views
1

問題説明

を解雇されていない私はcaptainhookがモデルのために働くために取得しようと、そうすることができませんでしたされています。 CaptainHookは、HTTPポストリクエストとしてイベントに基づいて指定したURLにイベントデータを送信するためのURLや雄弁なカスタムイベントを追加するPHPライブラリです。Laravel - モデルのeloquent.savedイベントが

私は間違いをどこで行っているのか分かりませんが、私はLaravelがeloquent.savedやその他のイベントを発していないと想定しています。私はreadmeに記載されているすべての正確な指示に従った。ここで

は、問題の解決に役立つかもしれない私のプロジェクトファイルです:

すべてのヘルプは大歓迎です。

PHP職人フック:リスト

+----+-----------+------------------------+----------------------------+ 
| id | tenant_id | url     | event      | 
+----+-----------+------------------------+----------------------------+ 
| 7 |   | http://localhost:10000 | eloquent.saved \App\Vessel | 
+----+-----------+------------------------+----------------------------+ 

composer.json

{ 
"name": "laravel/laravel", 
"description": "The Laravel Framework.", 
"keywords": [ 
    "framework", 
    "laravel" 
], 
"license": "MIT", 
"type": "project", 
"require": { 
    "laravel/framework": "5.2.39", 
    "league/flysystem-aws-s3-v3": "~1.0", 
    "venturecraft/revisionable": "1.*", 
    "maknz/slack": "^1.7", 
    "phpmailer/phpmailer": "^5.2", 
    "snowfire/beautymail": "dev-master", 
    "mpociot/captainhook": "~2.0", 
    "doctrine/dbal": "^2.5", 
    "predis/predis": "^1.1", 
    "torann/currency": "^0.3.0", 
    "yajra/laravel-datatables-oracle": "~6.0" 
}, 
"require-dev": { 
    "fzaninotto/faker": "~1.4", 
    "mockery/mockery": "0.9.*", 
    "phpunit/phpunit": "~4.0", 
    "symfony/css-selector": "2.8.*|3.0.*", 
    "symfony/dom-crawler": "2.8.*|3.0.*" 
}, 
"autoload": { 
    "classmap": [ 
    "database", 
    "app/Libraries/ImageUploaderPHP" 
    ], 
    "psr-4": { 
    "App\\": "app/" 
    }, 
    "files": [ 
    "app/Support/helpers.php" 
    ] 
}, 
"autoload-dev": { 
    "classmap": [ 
    "tests/TestCase.php" 
    ] 
}, 
"scripts": { 
    "post-root-package-install": [ 
    "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 
    ], 
    "post-create-project-cmd": [ 
    "php artisan key:generate" 
    ], 
    "post-install-cmd": [ 
    "Illuminate\\Foundation\\ComposerScripts::postInstall", 
    "php artisan optimize" 
    ], 
    "post-update-cmd": [ 
    "Illuminate\\Foundation\\ComposerScripts::postUpdate", 
    "php artisan optimize" 
    ] 
}, 
"config": { 
    "preferred-install": "dist", 
    "process-timeout": 0 
} 
} 

.env

APP_ENV=local 
APP_DEBUG=true 
APP_KEY=1yoaL71DDzGvey0BwVy25hySFMdBaEoA 

DB_HOST=127.0.0.1 
DB_DATABASE=myfyba 
DB_USERNAME=root 
DB_PASSWORD= 

CACHE_DRIVER=redis 
SESSION_DRIVER=redis 
QUEUE_DRIVER=redis 
REDIS_HOST=localhost 
.... 

のconfig/captain_hook.php

<?php 

/** 
* This file is part of CaptainHook arrrrr. 
* 
* @license MIT 
*/ 

return [ 

    /* 
    |-------------------------------------------------------------------------- 
    | Event listeners 
    |-------------------------------------------------------------------------- 
    | 
    | This array allows you to define all events that Captain Hook should 
    | listen for in the application. By default, the Captain will just 
    | respond to eloquent events, but you may edit this as you like. 
    */ 
    'listeners' => ['eloquent.*'], 

    /* 
    |-------------------------------------------------------------------------- 
    | Webhook filter closure 
    |-------------------------------------------------------------------------- 
    | 
    | If your webhooks are scoped to a tenant_id, you can modify 
    | this filter function to return only the webhooks for your 
    | tenant. This function is applied as a collection filter. 
    | The tenant_id field can be used for verification. 
    | 
    */ 
    'filter' => function ($webhook) { 
     return true; 
    }, 

    /* 
    |-------------------------------------------------------------------------- 
    | Webhook data transformer 
    |-------------------------------------------------------------------------- 
    | 
    | The data transformer is a simple function that allows you to take the 
    | subject data of an event and convert it to a format that will then 
    | be posted to the webhooks. By default, all data is json encoded. 
    | The second argument is the Webhook that was triggered in case 
    | you want to transform the data in different ways per hook. 
    | 
    | You can also use the 'Foo\[email protected]' notation if you want. 
    | 
    */ 
    'transformer' => function ($eventData, $webhook) { 
     return json_encode($eventData); 
    }, 

    /* 
    |-------------------------------------------------------------------------- 
    | Webhook response callback 
    |-------------------------------------------------------------------------- 
    | 
    | The response callback can be used if you want to trigger 
    | certain actions depending on the webhook response. 
    | This is unused by default. 
    | 
    | You can also use the 'Foo\[email protected]' notation if you want. 
    | 
    */ 
    'response_callback' => function ($webhook, $response) { 
     // Handle custom response status codes, ... 
    }, 

    /* 
    |-------------------------------------------------------------------------- 
    | Logging configuration 
    |-------------------------------------------------------------------------- 
    | 
    | Captain Hook ships with built-in logging to allow you to store data 
    | about the requests that you have made in a certain time interval. 
    */ 
    'log' => [ 
     'active' => true, 
     'storage_quantity' => 50, 
    ], 
]; 

答えて

1

このパッケージのドキュメントでは、eloquent.updated \App\Userという名前のイベントがイベントのイベントで発生しますが、実際にはeloquent.updated: App\Userというイベントが発生します。

はにあなたのウェブフックを変更してみてください:

eloquent.saved: App\Vessel

+0

ありがとう!私はそれを試して受け入れます。 –

+0

+1うんざりしました。どうもありがとう。どこから文書でこれを学んだのですか? –

+0

'Illuminate \ Database \ Eloquent \ Model @ fireModelEvent' ... $ event =" eloquent。$ event}: ".static :: class;"はイベントの発生を処理します。 – lagbox