Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
leeovery committed Feb 9, 2020
1 parent 7ead7bb commit 6647ce8
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 30 deletions.
6 changes: 6 additions & 0 deletions resources/views/app/webhooks/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<x-th sort-by="name" sort-default>Name</x-th>
<th>Url</th>
<th class="w-32 th-numeric">Triggers</th>
<th class="w-32 th-numeric">Fired</th>
<x-th sort-by="-created_at" class="w-48 th-numeric hidden | md:table-cell">Created</x-th>
<th class="w-12"></th>
</tr>
Expand Down Expand Up @@ -57,6 +58,11 @@
</div>
</td>
<td class="td-numeric">{{ $webhook->trigger_list_count }}</td>
<td class="td-numeric markup-links">
<a href="{{ route('mailcoach-api.webhooks.event-log', $webhook) }}">
{{ $webhook->webhookEvents()->count() }}
</a>
</td>
<td class="td-numeric hidden | md:table-cell">
{{ $webhook->created_at->toMailcoachFormat() }}
</td>
Expand Down
18 changes: 9 additions & 9 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

use Illuminate\Support\Facades\Route;
use Leeovery\MailcoachApi\Http\App\Controllers\ClientIndexController;
use Leeovery\MailcoachApi\Http\App\Controllers\EditWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\CreateClientController;
use Leeovery\MailcoachApi\Http\App\Controllers\WebhookIndexController;
use Leeovery\MailcoachApi\Http\App\Controllers\DestroyClientController;
use Leeovery\MailcoachApi\Http\App\Controllers\CreateWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\DestroyWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\ActivateWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\DeactivateWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\Clients\ClientIndexController;
use Leeovery\MailcoachApi\Http\App\Controllers\Webhooks\EditWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\Clients\CreateClientController;
use Leeovery\MailcoachApi\Http\App\Controllers\Webhooks\WebhookIndexController;
use Leeovery\MailcoachApi\Http\App\Controllers\Clients\DestroyClientController;
use Leeovery\MailcoachApi\Http\App\Controllers\Webhooks\CreateWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\Webhooks\DestroyWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\Webhooks\ActivateWebhookController;
use Leeovery\MailcoachApi\Http\App\Controllers\Webhooks\WebhookEventLogController;
use Leeovery\MailcoachApi\Http\App\Controllers\Webhooks\DeactivateWebhookController;

Route::prefix('api')->group(function () {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Clients;

use Laravel\Passport\Client;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Clients;

use Laravel\Passport\ClientRepository;
use Leeovery\MailcoachApi\Http\App\Requests\CreateApiClientRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Clients;

use Laravel\Passport\Client;
use Laravel\Passport\ClientRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Webhooks;

use Leeovery\MailcoachApi\Models\Webhook;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Webhooks;

use Leeovery\MailcoachApi\Models\Webhook;
use Leeovery\MailcoachApi\Http\App\Requests\CreateWebhookRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Webhooks;

use Leeovery\MailcoachApi\Models\Webhook;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Webhooks;

use Leeovery\MailcoachApi\Models\Webhook;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Webhooks;

use Leeovery\MailcoachApi\Models\Webhook;
use Leeovery\MailcoachApi\Support\Triggers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leeovery\MailcoachApi\Http\App\Controllers;
namespace Leeovery\MailcoachApi\Http\App\Controllers\Webhooks;

use Leeovery\MailcoachApi\Models\Webhook;
use Leeovery\MailcoachApi\Http\App\Queries\WebhookQuery;
Expand Down
2 changes: 1 addition & 1 deletion src/MailcoachApiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function register()
$this->mergeConfigFrom(__DIR__.'/../config/mailcoach-api.php', 'mailcoach-api');

$this->app->singleton(Triggers::class, function () {
return new Triggers(collect($this->actionMap));
return new Triggers($this->actionMap);
});

Event::listen('Spatie\Mailcoach\Events\*', MailcoachEventListener::class);
Expand Down
15 changes: 4 additions & 11 deletions src/Support/Triggers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,20 @@

use Illuminate\Support\Collection;

class Triggers
class Triggers extends Collection
{
private Collection $eventMap;

public function __construct(Collection $eventMap)
{
$this->eventMap = $eventMap;
}

public function events()
{
return $this->eventMap->values();
return $this->values();
}

public function hasEvent($event)
{
return $this->eventMap->has($event);
return $this->has($event);
}

public function getTriggerKey($event)
{
return $this->eventMap->get($event);
return $this->get($event);
}
}

0 comments on commit 6647ce8

Please sign in to comment.