我使用的是长丝PHP并创建了一个名为UserResource
的资源。这个资源注册在我的灯丝插件的ServiceProvider中:
namespace musa11971MyPlugin;
use FilamentPluginServiceProvider;
use musa11971MyPluginResourcesUserResource;
use SpatieLaravelPackageToolsPackage;
class MyPluginProvider extends PluginServiceProvider
{
protected array $resources = [
UserResource::class
];
public function configurePackage(Package $package): void
{
$package->name('my-plugin')
->hasTranslations();
}
public function boot()
{
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'my-plugin');
}
}
我所有的页面/组件加载良好,但当我与组件交互(例如点击一个按钮),一个Livewire异常抛出:
Unable to find component: [musa11971.my-plugin.resources.user-resource.pages.edit-user
解决方案是在您的Service Provider的引导方法中调用parent::boot()
。
public function boot()
{
parent::boot();
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'my-plugin');
}
try this:
public function packageBooted(): void
{
parent::packageBooted();
// Do somthing...
}