fix: use booted for safe facade usage

This commit is contained in:
Ryan Chandler
2021-03-12 14:30:44 +00:00
parent 065ad22698
commit b4ce95a60d
+17 -16
View File
@@ -3,15 +3,10 @@
namespace Filament;
use Illuminate\Support\ServiceProvider;
use Illuminate\Filesystem\Filesystem;
use Livewire\LiveWire;
use ReflectionClass;
use Str;
use Symfony\Component\Finder\SplFileInfo;
use Livewire\Livewire;
abstract class PluginServiceProvider extends ServiceProvider
{
protected $pages = [];
protected $resources = [];
@@ -37,16 +32,6 @@ abstract class PluginServiceProvider extends ServiceProvider
Filament::registerResource($resource);
}
foreach ($this->resources() as $resource) {
foreach ($resource::relations() as $relation) {
Livewire::component($relation::getName(), $relation);
}
foreach ($resource::routes() as $route) {
Livewire::component($route->page::getName(), $route->page);
}
}
foreach ($this->roles() as $role) {
Filament::registerRole($role);
}
@@ -68,6 +53,22 @@ abstract class PluginServiceProvider extends ServiceProvider
});
});
$this->app->booted(function () {
foreach ($this->pages() as $page) {
Livewire::component($page::getName(), $page);
}
foreach ($this->resources() as $resource) {
foreach ($resource::relations() as $relation) {
Livewire::component($relation::getName(), $relation);
}
foreach ($resource::routes() as $route) {
Livewire::component($route->page::getName(), $route->page);
}
}
});
$this->pluginRegistered();
}