Reputation: 143
Is it possible to override a package provided event?
For example
Package "laravel/cashier-mollie" which is installed via composer into the vendor dir has an event laravel\cashier-mollie\src\Events\OrderPaymentFailed
What I want to do is update a specific field in my database when this event is fired.
Any ideas?
Upvotes: 0
Views: 1235
Reputation: 5452
You can add your own Listener for the event in app/Providers/EventServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use Laravel\Cashier\Events\OrderPaymentFailed;
use App\Listeners\OrderPaymentsFailedListener;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
OrderPaymentFailed::class => [
// Your custom listener
OrderPaymentsFailedListener::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
//
}
}
Upvotes: 3