Skip to content

Commit d3586eb

Browse files
[10.x] Allow DatabaseRefreshed event to include given database and seed options (#47923)
* [10.x] Allow DatabaseRefreshed event to include given `database` and `seed` options This would be useful to know if `migrate:fresh` or `migrate:refresh` was executed with `--seed` or `--database` option. Signed-off-by: Mior Muhammad Zaki <[email protected]> * Update DatabaseRefreshed.php --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent dd4b2a9 commit d3586eb

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Illuminate/Database/Console/Migrations/FreshCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function handle()
6161

6262
if ($this->laravel->bound(Dispatcher::class)) {
6363
$this->laravel[Dispatcher::class]->dispatch(
64-
new DatabaseRefreshed
64+
new DatabaseRefreshed($database, $this->needsSeeding())
6565
);
6666
}
6767

src/Illuminate/Database/Console/Migrations/RefreshCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function handle()
6767

6868
if ($this->laravel->bound(Dispatcher::class)) {
6969
$this->laravel[Dispatcher::class]->dispatch(
70-
new DatabaseRefreshed
70+
new DatabaseRefreshed($database, $this->needsSeeding())
7171
);
7272
}
7373

src/Illuminate/Database/Events/DatabaseRefreshed.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,17 @@
66

77
class DatabaseRefreshed implements MigrationEventContract
88
{
9-
//
9+
/**
10+
* Create a new event instance.
11+
*
12+
* @param string|null $database
13+
* @param bool seeding
14+
* @return void
15+
*/
16+
public function __construct(
17+
public ?string $database = null,
18+
public bool $seeding = false
19+
) {
20+
//
21+
}
1022
}

0 commit comments

Comments
 (0)