laravel ComponentNotFoundException:无法找到使用Filament PHP插件的组件

8cdiaqws  于 2023-04-07  发布在  PHP
关注(0)|答案(1)|浏览(165)

我正在使用Filament PHP并创建了一个名为UserResource的资源。此资源在我的Filament插件的ServiceProvider中注册:

namespace musa11971\MyPlugin;

use Filament\PluginServiceProvider;
use musa11971\MyPlugin\Resources\UserResource;
use Spatie\LaravelPackageTools\Package;

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
qxgroojn

qxgroojn1#

解决方案是在Service Provider的 Boot 方法中调用parent::boot()

public function boot()
    {
        parent::boot();
        
        $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'my-plugin');
    }

相关问题