Skip to content

Commit 553ea01

Browse files
Give new app instance to database manager (#225)
* give new app instance to database manager * Update ProvidesDefaultConfigurationOptions.php * Update GiveNewApplicationInstanceToDatabaseManager.php * Apply fixes from StyleCI (#226) Co-authored-by: Taylor Otwell <[email protected]>
1 parent 83f7687 commit 553ea01

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Concerns/ProvidesDefaultConfigurationOptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static function prepareApplicationForNextOperation(): array
3434
\Laravel\Octane\Listeners\CreateConfigurationSandbox::class,
3535
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToAuthorizationGate::class,
3636
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToBroadcastManager::class,
37+
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToDatabaseManager::class,
3738
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToHttpKernel::class,
3839
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToMailManager::class,
3940
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToNotificationChannelManager::class,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Laravel\Octane\Listeners;
4+
5+
class GiveNewApplicationInstanceToDatabaseManager
6+
{
7+
/**
8+
* Handle the event.
9+
*
10+
* @param mixed $event
11+
* @return void
12+
*/
13+
public function handle($event): void
14+
{
15+
if (! $event->sandbox->resolved('db') ||
16+
! method_exists($event->sandbox->make('db'), 'setApplication')) {
17+
return;
18+
}
19+
20+
with($event->sandbox->make('db'), function ($manager) use ($event) {
21+
$manager->setApplication($event->sandbox);
22+
});
23+
}
24+
}

0 commit comments

Comments
 (0)