Laravel Migration event listeners doesn't work.
config/app.php
'providers' => [
...
App\Providers\EventServiceProvider::class,
....
app/Providers/EventServiceProvider.php
namespace App\Providers;
use App\Listeners\DeleteUnitsImagesFromAws;
use Illuminate\Database\Events\MigrationsStarted;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
MigrationsStarted::class => [
DeleteUnitsImagesFromAws::class,
]
];
public function boot()
{
parent::boot();
Event::listen(MigrationsStarted::class, function($event) {
\Log::channel('payment')->info(['class' => 'DeleteUnitsImagesFromAws']);
});
}
}
The above logs are not working, but the following is working.
namespace Illuminate\Database\Events;
use Illuminate\Contracts\Database\Events\MigrationEvent as MigrationEventContract;
class MigrationsStarted implements MigrationEventContract
{
public function __construct()
{
\Log::channel('daily')->info(['class' => '1000']);
}
}
How should I listen this event?