G
G
gasparian-marine42020-05-13 13:25:07
Laravel
gasparian-marine4, 2020-05-13 13:25:07

Laravel migration events don't fire?

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 to this event?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gasparyan-marine4, 2020-05-14
@gasparian-marine4

Solved , see here
https://stackoverflow.com/questions/61749800/liste...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question