@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('webhook_logs', function (Blueprint $table) { |
|
| 15 | + Schema::create('webhook_logs', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->integer('webhook_id')->unsigned()->nullable(); |
| 18 | 18 | $table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('set null'); |
@@ -31,16 +31,16 @@ |
||
| 31 | 31 | { |
| 32 | 32 | parent::boot(); |
| 33 | 33 | |
| 34 | - static::created(function ($results) { |
|
| 34 | + static::created(function($results) { |
|
| 35 | 35 | Cache::forget(self::CACHE_KEY); |
| 36 | 36 | }); |
| 37 | 37 | |
| 38 | 38 | |
| 39 | - static::updated(function ($results) { |
|
| 39 | + static::updated(function($results) { |
|
| 40 | 40 | Cache::forget(self::CACHE_KEY); |
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | - static::deleted(function ($results) { |
|
| 43 | + static::deleted(function($results) { |
|
| 44 | 44 | Cache::forget(self::CACHE_KEY); |
| 45 | 45 | }); |
| 46 | 46 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | | The tenant_id field can be used for verification. |
| 31 | 31 | | |
| 32 | 32 | */ |
| 33 | - 'filter' => function ($webhook) { |
|
| 33 | + 'filter' => function($webhook) { |
|
| 34 | 34 | return true; |
| 35 | 35 | }, |
| 36 | 36 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | | You can also use the 'Foo\Class@transform' notation if you want. |
| 49 | 49 | | |
| 50 | 50 | */ |
| 51 | - 'transformer' => function ($eventData, $webhook) { |
|
| 51 | + 'transformer' => function($eventData, $webhook) { |
|
| 52 | 52 | return json_encode($eventData); |
| 53 | 53 | }, |
| 54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | | You can also use the 'Foo\Class@handle' notation if you want. |
| 66 | 66 | | |
| 67 | 67 | */ |
| 68 | - 'response_callback' => function ($webhook, $response) { |
|
| 68 | + 'response_callback' => function($webhook, $response) { |
|
| 69 | 69 | // Handle custom response status codes, ... |
| 70 | 70 | }, |
| 71 | 71 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -Route::group(['middleware' => ['web', 'auth']], function ($router) { |
|
| 3 | +Route::group(['middleware' => ['web', 'auth']], function($router) { |
|
| 4 | 4 | $router->get('/settings/api/webhooks', 'Mpociot\CaptainHook\Http\WebhookController@all'); |
| 5 | 5 | $router->post('/settings/api/webhook', 'Mpociot\CaptainHook\Http\WebhookController@store'); |
| 6 | 6 | $router->put('/settings/api/webhook/{webhook_id}', 'Mpociot\CaptainHook\Http\WebhookController@update'); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | }); |
| 11 | 11 | |
| 12 | 12 | if (config('captain_hook.uses_api', false)) { |
| 13 | - Route::group(['middleware' => 'auth:api', 'prefix' => 'api'], function ($router) { |
|
| 13 | + Route::group(['middleware' => 'auth:api', 'prefix' => 'api'], function($router) { |
|
| 14 | 14 | $router->get('webhooks', 'Mpociot\CaptainHook\Http\WebhookController@all'); |
| 15 | 15 | $router->post('webhook', 'Mpociot\CaptainHook\Http\WebhookController@store'); |
| 16 | 16 | $router->put('webhook/{webhook_id}', 'Mpociot\CaptainHook\Http\WebhookController@update'); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | private function resolveCallable($transformer, $defaultMethodName) |
| 55 | 55 | { |
| 56 | 56 | if (is_string($transformer)) { |
| 57 | - return function () use ($transformer, $defaultMethodName) { |
|
| 57 | + return function() use ($transformer, $defaultMethodName) { |
|
| 58 | 58 | list($class, $method) = Str::parseCallback($transformer, $defaultMethodName); |
| 59 | 59 | |
| 60 | 60 | return call_user_func_array([app($class), $method], func_get_args()); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | return $transformer; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - return function () { |
|
| 66 | + return function() { |
|
| 67 | 67 | }; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | 'webhook_id' => $webhook['id'], |
| 96 | 96 | 'url' => $webhook['url'], |
| 97 | 97 | ]); |
| 98 | - $middleware = Middleware::tap(function (RequestInterface $request, $options) use ($log) { |
|
| 98 | + $middleware = Middleware::tap(function(RequestInterface $request, $options) use ($log) { |
|
| 99 | 99 | $log->payload_format = isset($request->getHeader('Content-Type')[0]) ? $request->getHeader('Content-Type')[0] : null; |
| 100 | 100 | $log->payload = $request->getBody()->getContents(); |
| 101 | - }, function ($request, $options, PromiseInterface $response) use ($log, $webhook, $responseCallback) { |
|
| 102 | - $response->then(function (ResponseInterface $response) use ($log, $webhook, $responseCallback) { |
|
| 101 | + }, function($request, $options, PromiseInterface $response) use ($log, $webhook, $responseCallback) { |
|
| 102 | + $response->then(function(ResponseInterface $response) use ($log, $webhook, $responseCallback) { |
|
| 103 | 103 | $log->status = $response->getStatusCode(); |
| 104 | 104 | $log->response = $response->getBody()->getContents(); |
| 105 | 105 | $log->response_format = $log->payload_format = isset($response->getHeader('Content-Type')[0]) ? $response->getHeader('Content-Type')[0] : null; |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('webhooks', function (Blueprint $table) { |
|
| 15 | + Schema::create('webhooks', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->integer('tenant_id')->unsigned()->nullable(); |
| 18 | 18 | $table->string('url'); |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function registerEventDispatcher() |
| 91 | 91 | { |
| 92 | - $this->app->singleton('events', function ($app) { |
|
| 93 | - return (new EventDispatcher($app))->setQueueResolver(function () use ($app) { |
|
| 92 | + $this->app->singleton('events', function($app) { |
|
| 93 | + return (new EventDispatcher($app))->setQueueResolver(function() use ($app) { |
|
| 94 | 94 | return $app->make(QueueFactoryContract::class); |
| 95 | 95 | }); |
| 96 | 96 | }); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | public function setWebhooks($webhooks) |
| 167 | 167 | { |
| 168 | 168 | $this->webhooks = $webhooks; |
| 169 | - $this->getCache()->rememberForever(Webhook::CACHE_KEY, function () { |
|
| 169 | + $this->getCache()->rememberForever(Webhook::CACHE_KEY, function() { |
|
| 170 | 170 | return $this->webhooks; |
| 171 | 171 | }); |
| 172 | 172 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | // Check if migration ran |
| 180 | 180 | if (Schema::hasTable((new Webhook)->getTable())) { |
| 181 | - return collect($this->getCache()->rememberForever(Webhook::CACHE_KEY, function () { |
|
| 181 | + return collect($this->getCache()->rememberForever(Webhook::CACHE_KEY, function() { |
|
| 182 | 182 | return Webhook::all(); |
| 183 | 183 | })); |
| 184 | 184 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $webhooks = $this->getWebhooks()->where('event', $eventName); |
| 230 | 230 | $webhooks = $webhooks->filter($this->config->get('captain_hook.filter', null)); |
| 231 | 231 | |
| 232 | - if (! $webhooks->isEmpty()) { |
|
| 232 | + if (!$webhooks->isEmpty()) { |
|
| 233 | 233 | $this->dispatch(new TriggerWebhooksJob($webhooks, $eventData)); |
| 234 | 234 | } |
| 235 | 235 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function all(Request $request) |
| 26 | 26 | { |
| 27 | - return collect(config('captain_hook.listeners', []))->transform(function ($key, $value) { |
|
| 27 | + return collect(config('captain_hook.listeners', []))->transform(function($key, $value) { |
|
| 28 | 28 | return [ |
| 29 | 29 | 'name' => $value, |
| 30 | 30 | 'event' => $key, |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | // If a response is returned from the listener and event halting is enabled |
| 55 | 55 | // we will just return this response, and not call the rest of the event |
| 56 | 56 | // listeners. Otherwise we will add the response on the response list. |
| 57 | - if (! is_null($response) && $halt) { |
|
| 57 | + if (!is_null($response) && $halt) { |
|
| 58 | 58 | array_pop($this->firing); |
| 59 | 59 | |
| 60 | 60 | return $response; |