F
Filament2y ago
flex

How to load my Resources, etc. in a Laravel Package?

Hello! I am currently developing a small Laravel CMS Package. I have some resources for pages, etc. Filament in general loads successfully (added Filament to the composer of the package). But my resources from the packages /src/Filament folder don't get loaded. My filament dashboard is just empty. How can I define, that the package should also load my Resource files from the src/Filament folder?
7 Replies
Dan Harrin
Dan Harrin2y ago
in packages we dont do autodiscovery you should use Filament::registerResources() like the plugin docs say
flex
flexOP2y ago
@Dan Harrin Hm, in my package's main ServiceProvider I register a FilamentServiceProvider. In this FilamentServiceProvider I define the $resources array. This error log. got fired but Filament still doesn't care about the resources. May I described my case little bit confusing: I don't develop a plugin for Filament. I develop a package (CMS) for Laravel which uses Filament.
Dan Harrin
Dan Harrin2y ago
its the same as a plugin what are the IDE errors there
flex
flexOP2y ago
its an IDE problem. PluginServiceProvider and Package is loaded correctly. Hm, but can't see steps in the Plugin Docs I didn't follow. Ah $this->app->register(FilamentServiceProvider::class); doesn't work for the PluginServiceProvider - is this possible? So, I can't register this provider in my main package provider. Instead I need to put it into the composer's extra.laravel.providers
Dan Harrin
Dan Harrin2y ago
yeah this is like every laravel package though you should register service providers in the composer.json check out spatie's package skeleton
Andrew Wallo
Andrew Wallo2y ago
If you aren't using spatie's package it is also very easy to register resources, pages, etc... You can check out how I registered them here in my package: https://github.com/andrewdwallo/filament-companies/blob/1.x/src/FilamentCompaniesServiceProvider.php
GitHub
filament-companies/FilamentCompaniesServiceProvider.php at 1.x · an...
Contribute to andrewdwallo/filament-companies development by creating an account on GitHub.
Andrew Wallo
Andrew Wallo2y ago
I have pages but similar use case for Resources just a little different...
Want results from more Discord servers?
Add your server