Dependency injection.
How can i inject a service in filament ? i try method construct but it makes error
8 Replies
Dependencies are injected in
mount()
in Livewire components. You can also use app()
to resolve them from the container.Depends on what you're trying to do... Use
mount()
if the service is only needed once when the page is initialized or use boot()
if the service is needed for every subsequent request/action.where do you actually need the service
i have a button named export in list screen. When user click it. I export a file for user. So i think i must inject service in ListRecords. Do I think that's right?
you have an Action?
Yes, i have an action for user export and download file
->action(fn (YourServiceHere $service) => ...)
you can inject in that functionOk, Let me try. Filament is great. Let's keep developing it