getHeaderWidgets on simple Resource

how can i add getHeaderWidgets on simple resource ??
5 Replies
Dennis Koch
Dennis Koch2y ago
You can't. Modals don't support widgets.
Lambertn33
Lambertn33OP2y ago
thanks for this @Dennis Koch one last question for today is: can I prevent to go to a certain page when a certain model in DB has no records? eg: I have a Post model and Comment model Post has Many Comments I want to prevent to go to comments/create while Post::count() == 0; Thank you!
Dan Harrin
Dan Harrin2y ago
you can add widgets above the table, by putting them in getHeaderWidgets() on the manage page but not inside modals
Lambertn33
Lambertn33OP2y ago
It failed... I don't know why!
ehbfa
ehbfa2y ago
@lambertn33 you can put widgets in a modal with custom code in a resource (not sure about a simple resource, haven't tested that). I had to do a similar thing. I made a custom action in my resource:
Tables\Actions\Action::make('insights')
->action(function() {})
->modalActions([])
->modalContent(view('filament.pages.companies.insights')),
Tables\Actions\Action::make('insights')
->action(function() {})
->modalActions([])
->modalContent(view('filament.pages.companies.insights')),
Then I made that blade view with this content:
<div class="grid grid-cols-1 lg:grid-cols-2 filament-widgets-container gap-4 lg:gap-8 mb-6">
@livewire(\Livewire\Livewire::getAlias(App\Filament\Widgets\DoughnutChart::class))
</div>
<div class="grid grid-cols-1 lg:grid-cols-2 filament-widgets-container gap-4 lg:gap-8 mb-6">
@livewire(\Livewire\Livewire::getAlias(App\Filament\Widgets\DoughnutChart::class))
</div>
Want results from more Discord servers?
Add your server