2016-10-11 2 views
1

문제 설명

를 해고하지 않으며 그렇게 할 수 없습니다입니다. Captainhook은 PHP 포스트 스크립트로 이벤트를 기반으로 지정하는 URL에 이벤트 데이터를 보내기위한 URL 및 웅변 적 이벤트 또는 맞춤 이벤트를 추가합니다.Laravel은 - 모델 eloquent.saved 이벤트 내가 모델 일을 <a href="https://github.com/mpociot/captainhook" rel="nofollow">captainhook</a>를 얻기 위해 노력 해왔다

내가 실수를하고 있는지 확실하지 않지만 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 
.... 

구성/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이라는 이벤트가 발생합니다.

는 귀하으로 webhook을 변경해보십시오 :

eloquent.saved: App\Vessel

+0

감사합니다! 나는 그것을 시도하고 받아 들일 것이다. –

+0

+1 저주했다. 고마워. 문서 또는 다른 곳에서 어디에서 이것을 배웠습니까? –

+0

'Illuminate \ Database \ Eloquent \ Model @ fireModelEvent' ... $ event = "eloquent. $ event} :".static :: class; "이벤트를 실행하는 것을 처리합니다. – lagbox