Skip to content

Commit c120d73

Browse files
committed
fix: use standard Nova::serving() pattern for asset registration
The previous $app->resolving() pattern was not correctly registering the JavaScript assets with Nova, causing the Vue components to never be loaded in the browser. Switched to the standard Nova asset registration pattern: - Import Laravel\Nova\Events\ServingNova - Use Nova::serving() directly in boot()
1 parent 9029da0 commit c120d73

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/FieldServiceProvider.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@
55
namespace Iamgerwin\NovaDependencyContainer;
66

77
use Illuminate\Support\ServiceProvider;
8+
use Laravel\Nova\Events\ServingNova;
9+
use Laravel\Nova\Nova;
810

911
class FieldServiceProvider extends ServiceProvider
1012
{
13+
/**
14+
* Bootstrap any application services.
15+
*/
1116
public function boot(): void
1217
{
13-
if (class_exists('Laravel\Nova\Nova')) {
14-
$this->app->resolving('Laravel\Nova\Nova', function ($nova): void {
15-
\Laravel\Nova\Nova::serving(function ($event): void {
16-
\Laravel\Nova\Nova::script('nova-dependency-container', __DIR__ . '/../dist/js/field.js');
17-
\Laravel\Nova\Nova::style('nova-dependency-container', __DIR__ . '/../dist/css/field.css');
18-
});
19-
});
20-
}
18+
Nova::serving(function (ServingNova $event): void {
19+
Nova::script('nova-dependency-container', __DIR__ . '/../dist/js/field.js');
20+
Nova::style('nova-dependency-container', __DIR__ . '/../dist/css/field.css');
21+
});
22+
}
23+
24+
/**
25+
* Register any application services.
26+
*/
27+
public function register(): void
28+
{
29+
//
2130
}
2231
}

0 commit comments

Comments
 (0)