Skip to content

Commit

Permalink
Merge pull request #26 from mpociot/analysis-zGDLMg
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
mpociot committed Apr 16, 2016
2 parents 73f018a + f3dbefa commit 3e223a5
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 22 deletions.
15 changes: 8 additions & 7 deletions src/Mpociot/CaptainHook/CaptainHookServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function publishSparkResources()

$this->publishes([
__DIR__.'/../../resources/assets/js/' => base_path('resources/assets/js/components/'),
__DIR__ . '/../../resources/views/' => base_path('resources/views/vendor/captainhook/settings/'),
__DIR__.'/../../resources/views/' => base_path('resources/views/vendor/captainhook/settings/'),
], 'spark-resources');
}

Expand All @@ -122,7 +122,7 @@ protected function publishSparkResources()
protected function registerEventListeners()
{
foreach ($this->listeners as $eventName) {
$this->app[ 'events' ]->listen($eventName, [$this, 'handleEvent']);
$this->app['events']->listen($eventName, [$this, 'handleEvent']);
}
}

Expand Down Expand Up @@ -214,15 +214,15 @@ public function handleEvent($eventData)
*/
protected function registerCommands()
{
$this->app[ 'hook.list' ] = $this->app->share(function () {
$this->app['hook.list'] = $this->app->share(function () {
return new ListWebhooks();
});

$this->app[ 'hook.add' ] = $this->app->share(function () {
$this->app['hook.add'] = $this->app->share(function () {
return new AddWebhook();
});

$this->app[ 'hook.delete' ] = $this->app->share(function () {
$this->app['hook.delete'] = $this->app->share(function () {
return new DeleteWebhook();
});

Expand All @@ -232,13 +232,14 @@ protected function registerCommands()
'hook.delete'
);
}

/**
* Register predefined routes used for Spark
* Register predefined routes used for Spark.
*/
protected function registerRoutes()
{
if (class_exists('Laravel\Spark\Providers\AppServiceProvider')) {
include __DIR__ . '/../../routes.php';
include __DIR__.'/../../routes.php';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public function authorize()
{
return true;
}

/**
* @return array
*/
public function rules()
{
return [
'url' => 'required|url',
'event' => 'required'
'event' => 'required',
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public function authorize()
{
return true;
}

/**
* @return array
*/
public function rules()
{
return [
'url' => 'required|url',
'event' => 'required'
'event' => 'required',
];
}
}
3 changes: 1 addition & 2 deletions src/Mpociot/CaptainHook/Http/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

class WebhookController extends Controller
{

/**
* Create a new controller instance.
*
Expand Down Expand Up @@ -46,7 +45,7 @@ public function store(CreateWebhookRequest $request)
$hook = Webhook::create([
'url' => $request->url,
'tenant_id' => $request->user()->getKey(),
'event' => $request->event
'event' => $request->event,
]);

return response()->json($hook);
Expand Down
3 changes: 1 addition & 2 deletions src/Mpociot/CaptainHook/Http/WebhookEventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class WebhookEventsController extends Controller
{

/**
* Create a new controller instance.
*
Expand All @@ -28,7 +27,7 @@ public function all(Request $request)
return collect(config('captain_hook.listeners', []))->transform(function ($key, $value) {
return [
'name' => $value,
'event' => $key
'event' => $key,
];
})->values();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Mpociot/CaptainHook/Jobs/TriggerWebhooksJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public function handle()
$webhook->logs()->orderBy('updated_at', 'desc')->first()->delete();
}
$log = new WebhookLog([
'webhook_id' => $webhook[ 'id' ],
'url' => $webhook[ 'url' ],
'webhook_id' => $webhook['id'],
'url' => $webhook['url'],
]);
$middleware = Middleware::tap(function (RequestInterface $request, $options) use ($log) {
$log->payload_format = isset($request->getHeader('Content-Type')[0]) ? $request->getHeader('Content-Type')[0] : null;
Expand All @@ -110,14 +110,14 @@ public function handle()
});
});

$client->post($webhook[ 'url' ], [
$client->post($webhook['url'], [
'exceptions' => false,
'body' => $transformer($this->eventData, $webhook),
'verify' => false,
'handler' => $middleware($client->getConfig('handler')),
]);
} else {
$client->post($webhook[ 'url' ], [
$client->post($webhook['url'], [
'exceptions' => false,
'body' => $transformer($this->eventData, $webhook),
'verify' => false,
Expand Down
2 changes: 1 addition & 1 deletion src/Mpociot/CaptainHook/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public function logs()
*/
public function lastLog()
{
return $this->hasOne(WebhookLog::class)->orderBy('created_at','DESC');
return $this->hasOne(WebhookLog::class)->orderBy('created_at', 'DESC');
}
}
2 changes: 1 addition & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
| respond to eloquent events, but you may edit this as you like.
*/
'listeners' => [
'Eloquent' => 'eloquent.*'
'Eloquent' => 'eloquent.*',
],

/*
Expand Down
2 changes: 1 addition & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
$router->delete('/settings/api/webhook/{webhook_id}', 'Mpociot\CaptainHook\Http\WebhookController@destroy');

$router->get('/settings/api/webhooks/events', 'Mpociot\CaptainHook\Http\WebhookEventsController@all');
});
});

0 comments on commit 3e223a5

Please sign in to comment.