Laravel Migration events don't fire #32778
Answered
by
lupinitylabs
gasparyanm
asked this question in
General
-
Laravel Migration event listeners don't work in my case. config/app.php 'providers' => [
...
App\Providers\EventServiceProvider::class,
.... namespace App\Providers;
use App\Listeners\DeleteUnitsAwsImages;
use Illuminate\Database\Events\MigrationsStarted;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
MigrationsStarted::class => [
DeleteUnitsAwsImages::class,
]
];
.... Listener <?php
namespace App\Listeners;
use Illuminate\Foundation\Events\Dispatchable;
class DeleteUnitsAwsImages
{
use Dispatchable;
public function __construct()
{
\Log::channel('daily')->info(['class' => '11111111111']);
}
public function handle()
{
\Log::channel('daily')->info(['class' => '22222222']);
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
lupinitylabs
May 13, 2020
Replies: 2 comments 4 replies
-
What events are registered? You can see this by running |
Beta Was this translation helpful? Give feedback.
1 reply
-
@M45678 Your code above works flawlessly for me on a fresh Laravel 7.11.0. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
gasparyanm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@M45678 Your code above works flawlessly for me on a fresh Laravel 7.11.0.
Have you made sure your logging setup works? Try putting a
dd('Test')
in thehandle()
method ofDeleteUnitsAwsImages
and do anartisan migrate fresh
to test the setup.