Skip to content

Commit

Permalink
Swapped Illuminate EventServiceProvider in favor of plain ServiceProv…
Browse files Browse the repository at this point in the history
…ider
  • Loading branch information
sandervanhooft committed Jun 18, 2024
1 parent 857c635 commit 8b40c9c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
16 changes: 15 additions & 1 deletion src/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Laravel\Cashier;

use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\ServiceProvider;
use Laravel\Cashier\Order\OrderInvoiceSubscriber;

class EventServiceProvider extends ServiceProvider
Expand All @@ -15,4 +17,16 @@ class EventServiceProvider extends ServiceProvider
protected $subscribe = [
OrderInvoiceSubscriber::class,
];

/**
* Bootstrap any application services.
*
* @param Dispatcher $events
* @return void
*/
public function boot(Dispatcher $events)
{
collect($this->subscribe)
->each(fn(string $subscriber) => $events->subscribe($subscriber));
}
}
13 changes: 4 additions & 9 deletions src/Order/OrderInvoiceSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@ public function handleOrderPaymentPaid($event)
*/
public function subscribe($events)
{
$events->listen(
OrderPaymentPaid::class,
self::class.'@handleOrderPaymentPaid'
);

$events->listen(
FirstPaymentPaid::class,
self::class.'@handleFirstPaymentPaid'
);
return [
OrderPaymentPaid::class => 'handleOrderPaymentPaid',
FirstPaymentPaid::class => 'handleFirstPaymentPaid',
];
}
}

0 comments on commit 8b40c9c

Please sign in to comment.