Задать вопрос
@gasparyan-marine4

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 this event?
  • Вопрос задан
  • 163 просмотра
Подписаться 1 Средний Комментировать
Решения вопроса 1
@gasparyan-marine4 Автор вопроса
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы