Phuc Le
Phuc Le
FFilament
Created by Phuc Le on 3/31/2024 in #❓┊help
Multi tenancy with multiple database support
When reading the documentation, it appears that Filament only supports multi-tenancy with a single database by using team_id. Is implementing multiple databases in the plan, or is it easily achievable with a workaround, or do I need to use a third-party package like stancl/tenancy or spatie/laravel-multitenancy?
44 replies
FFilament
Created by Phuc Le on 12/5/2023 in #❓┊help
Count selected records in Table Builder Bulk Action form
This is my code:
BulkAction::make('action')
->icon('heroicon-o-cog-6-tooth')
->deselectRecordsAfterCompletion()
->form(function (Collection $records) {
return [
Placeholder::make('Cost Breakdown')
->content('Selected: ' . number_format($records->count()))
];
}),
BulkAction::make('action')
->icon('heroicon-o-cog-6-tooth')
->deselectRecordsAfterCompletion()
->form(function (Collection $records) {
return [
Placeholder::make('Cost Breakdown')
->content('Selected: ' . number_format($records->count()))
];
}),
This will count the total of selected records and show it in the placeholder. However, if I close the modal and select one more record, the count does not change. It seems that Filament caches the modal content in subsequent requests. How can I get the fresh count data every time the modal opens?
2 replies
FFilament
Created by Phuc Le on 10/5/2023 in #❓┊help
Use Fieldset in Table Filter
Currently if I use Fieldset for SelectFilter, it will throw this error: Method Filament\Forms\Components\Fieldset::table does not exist.
Fieldset::make('Test')
->schema([
SelectFilter::make('test_1'),
SelectFilter::make('test_2'),
])
Fieldset::make('Test')
->schema([
SelectFilter::make('test_1'),
SelectFilter::make('test_2'),
])
I can use 2 Select forms and wrap them inside a Filter like this:
Filter::make('serp')
->form([
Fieldset::make('Test')->schema([
Select::make('test_1'),
Select::make('test_2'),
]),
]);
Filter::make('serp')
->form([
Fieldset::make('Test')->schema([
Select::make('test_1'),
Select::make('test_2'),
]),
]);
But I have to combine them into one query method and declare the indicator manually why using SelectFilter, it's done by Filament.
2 replies
FFilament
Created by Phuc Le on 10/4/2023 in #❓┊help
Using Tab component with Table Builder
I am using the Blade Tab component with Table Builder in my project:
<div>
<x-filament::tabs label="Content tabs">
@foreach($this->types as $key => $count)
<x-filament::tabs.item
:active="$key === $type"
wire:click="$set('type', '{{ $key }}')"
>
{{ $typeOptions[$key] ?? str($key)->headline() }}

<span class="sm:inline hidden">
({{ number_format($count) }})
</span>
</x-filament::tabs.item>
@endforeach
</x-filament::tabs>

{{ $this->table }}
</div>
<div>
<x-filament::tabs label="Content tabs">
@foreach($this->types as $key => $count)
<x-filament::tabs.item
:active="$key === $type"
wire:click="$set('type', '{{ $key }}')"
>
{{ $typeOptions[$key] ?? str($key)->headline() }}

<span class="sm:inline hidden">
({{ number_format($count) }})
</span>
</x-filament::tabs.item>
@endforeach
</x-filament::tabs>

{{ $this->table }}
</div>
The issue is when I click the tab, it will run $set('type', '{{ $key }}') to set the type, and I will load type in my $table->relationship() method like this:
$table
->relationship(fn() => $this->when($this->type), fn(Builder $query) => $query->where('type', $this->type)))
$table
->relationship(fn() => $this->when($this->type), fn(Builder $query) => $query->where('type', $this->type)))
The issue the table is not re-render when I click the tab in the 1st click, it only re-re-render when I click 2nd click (feel like defer effect). For example: If I click tab A, it doesn't show content of tab A in the table, but when I click tab B, then it show the content of tab A. And if I click tab C, it shows content of tab B.
9 replies
FFilament
Created by Phuc Le on 10/3/2023 in #❓┊help
Notification not shown
I am using the Notification & Table as a standalone package for my existing project. I tried to show a notification on the Delete action, but nothing is being displayed. I have already published all the assets of the Notification & Table in the vendor folder. Do I need to include a view somewhere?
$table->actions([
Action::make('delete')
->icon('heroicon-m-trash')
->color('danger')
->requiresConfirmation()
->modalHeading('Delete')
->action(function (Product $record) {
Notification::make()
->title('Saved successfully')
->success()
->send();
})
])
$table->actions([
Action::make('delete')
->icon('heroicon-m-trash')
->color('danger')
->requiresConfirmation()
->modalHeading('Delete')
->action(function (Product $record) {
Notification::make()
->title('Saved successfully')
->success()
->send();
})
])
2 replies