我想在完成文件迁移后立即触发一个事件,因为我想在表中添加一个额外的列。在该列中,我想复制另一列的所有数据。
Is there any way to check if migrations are ended
这是与体面的答案,但我不能理解不够的链接。
忽略这个
if ($userData['grant_type'] == 'refresh_token') {
$validator = Validator::make($userData, Config::get('boilerplate.refresh_token.validation_rules'));
} elseif ($userData['grant_type'] == 'password') {
$validator = Validator::make($userData, Config::get('boilerplate.login.validation_rules'));
}
字符串
2条答案
按热度按时间cbjzeqam1#
下面是使用数据库事件
MigrationsEnded
的最简单方法。首先,创建一个新的服务提供者类,例如:
php artisan make:provider CommandListenerProvider
个然后,将其添加到新提供程序,例如:
字符串
在
providers
阵列内的config/app.php
中注册您的提供程序。型
要测试它,只需运行
php artisan migrate
,您应该在dump()
函数中获得相同的文本。终端/控制台中的"You can set your logic here"
。然后,你就可以出发了!🎉
3yhwsihp2#
您应该创建一个侦听器,而不是像上面这样的服务提供程序。
你想监听
MigrationsEnded
事件,你可以像这样创建一个监听器。然后您需要在EventServiceProvider.php中注册事件侦听器
字符串
EventServiceProvider
型