Hugo
Hugo
FFilament
Created by Hugo on 7/30/2024 in #❓┊help
Closure on column action doesn't work
Hi, there, I'm trying to put an action on a column through a closure. I don't want the action to open if there is no $record->url, however, as soon as I pass a closure the action doesn't fire at all and the modal never opens. I've noticed that as soon as I pass a closure in the action, the click event is no longer “mountTableAction” but “callTableColumnAction”. If anyone has any ideas 😄
Tables\Columns\IconColumn::make('url')
->icon('heroicon-o-document')
->placeholder('No media')
->action(function ($record) {
if ($record->url) {
return Tables\Actions\Action::make()
->modal()
->modalContent(new HtmlString('<iframe src="' . $record->url . '" class="w-full h-full"></iframe>'))
->modalHeading($record->url);
} else {
return null;
}
})
Tables\Columns\IconColumn::make('url')
->icon('heroicon-o-document')
->placeholder('No media')
->action(function ($record) {
if ($record->url) {
return Tables\Actions\Action::make()
->modal()
->modalContent(new HtmlString('<iframe src="' . $record->url . '" class="w-full h-full"></iframe>'))
->modalHeading($record->url);
} else {
return null;
}
})
7 replies
FFilament
Created by Hugo on 4/18/2024 in #❓┊help
Navigate between records on ViewAction
No description
29 replies
FFilament
Created by Hugo on 12/21/2023 in #❓┊help
Group filters
How can I group these two filters so as to display the label above, in the same way as a Fieldset ? Or something similar
Filter::make('age_range')
->label('Tranche d\'âge')
->form([
TextInput::make('age_from')
->label('Âge minimum')
->numeric(),
TextInput::make('age_until')
->label('Âge maximum')
->numeric(),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['age_from'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '<=', now()->subYears($age)),
)
->when(
$data['age_until'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '>=', now()->subYears($age + 1)->addDay()),
);
}),
Filter::make('age_range')
->label('Tranche d\'âge')
->form([
TextInput::make('age_from')
->label('Âge minimum')
->numeric(),
TextInput::make('age_until')
->label('Âge maximum')
->numeric(),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['age_from'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '<=', now()->subYears($age)),
)
->when(
$data['age_until'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '>=', now()->subYears($age + 1)->addDay()),
);
}),
Thanks
6 replies
FFilament
Created by Hugo on 11/30/2023 in #❓┊help
Broken Paginator after composer update ?
Hi, I've just done a composer update on my project, and since then I've had this error that persists and totally blocks me. I don't understand how to solve the problem. Error :
PHP Fatal error: Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator in /home/hugo/projects/blouse-roses-v2/vendor/filament/tables/src/Concerns/CanPaginateRecords.php on line 28

Symfony\Component\ErrorHandler\Error\FatalError

Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator

at vendor/filament/tables/src/Concerns/CanPaginateRecords.php:28
24▕
25▕ $this->resetPage();
26▕ }
27▕
28▕ protected function paginateTableQuery(Builder $query): Paginator | CursorPaginator
29▕ {
30▕ $perPage = $this->getTableRecordsPerPage();
31▕
32▕ /** @var LengthAwarePaginator $records */


Whoops\Exception\ErrorException
PHP Fatal error: Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator in /home/hugo/projects/blouse-roses-v2/vendor/filament/tables/src/Concerns/CanPaginateRecords.php on line 28

Symfony\Component\ErrorHandler\Error\FatalError

Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator

at vendor/filament/tables/src/Concerns/CanPaginateRecords.php:28
24▕
25▕ $this->resetPage();
26▕ }
27▕
28▕ protected function paginateTableQuery(Builder $query): Paginator | CursorPaginator
29▕ {
30▕ $perPage = $this->getTableRecordsPerPage();
31▕
32▕ /** @var LengthAwarePaginator $records */


Whoops\Exception\ErrorException
If anyone has any ideas, please let me know. Thank you
7 replies
FFilament
Created by Hugo on 11/29/2023 in #❓┊help
Error with Filament after composer update
No description
7 replies
FFilament
Created by Hugo on 11/9/2023 in #❓┊help
Collapse all previous repeater items on addAction
Hi, On my repeater, what can I do so that when I click on the button to add an item, all previous items become collapsed? I can't find a solution in the documentation
Forms\Components\Repeater::make('services')
->label('Services')
->hintIcon('heroicon-o-information-circle', 'Ignorez cette étape si vous ne souhaitez pas associer de service au bénévole.')
->hintColor('primary')
->addActionLabel('Ajouter un service au bénévole')
->reorderableWithDragAndDrop(false)
->collapsible()
->defaultItems(0)
->itemLabel(fn(array $state): ?string => Service::find($state['service_id'])->serviceType->name ?? null)
->deleteAction(fn(Action $action) => $action->requiresConfirmation())
->schema([...]),
Forms\Components\Repeater::make('services')
->label('Services')
->hintIcon('heroicon-o-information-circle', 'Ignorez cette étape si vous ne souhaitez pas associer de service au bénévole.')
->hintColor('primary')
->addActionLabel('Ajouter un service au bénévole')
->reorderableWithDragAndDrop(false)
->collapsible()
->defaultItems(0)
->itemLabel(fn(array $state): ?string => Service::find($state['service_id'])->serviceType->name ?? null)
->deleteAction(fn(Action $action) => $action->requiresConfirmation())
->schema([...]),
Thanks for your help.
5 replies
FFilament
Created by Hugo on 11/7/2023 in #❓┊help
Default collapsed section does not work
Hi, I'm trying to make a collapsed section the default in my blade file. I followed the documentation (https://filamentphp.com/docs/3.x/support/blade-components/section), the collapsible works fine by itself, however when I add the collapsed, the section is not collapsed and the collapsible doesn't work anymore. Even without the collapsible, the collapsed doesn't work. Here's my code:
<x-filament-widgets::widget>

<x-filament::section
collapsible collapsed>
<x-slot name="heading">
Birth date anomalies &nbsp;
<x-filament::badge
style="display: inline-block">{{ $this->getTableQuery()->count() }}</x-filament::badge>
</x-slot>

{{ $this->table }}
</x-filament::section>

</x-filament-widgets::widget>
<x-filament-widgets::widget>

<x-filament::section
collapsible collapsed>
<x-slot name="heading">
Birth date anomalies &nbsp;
<x-filament::badge
style="display: inline-block">{{ $this->getTableQuery()->count() }}</x-filament::badge>
</x-slot>

{{ $this->table }}
</x-filament::section>

</x-filament-widgets::widget>
Do you have any ideas? Thanks for your help.
3 replies
FFilament
Created by Hugo on 10/2/2023 in #❓┊help
Get count of current online users
No description
8 replies
FFilament
Created by Hugo on 9/18/2023 in #❓┊help
How to make a YearPicker ?
Hi, I'm trying to make a DatePicker to select only years, how i can do that ?
Forms\Components\DatePicker::make('year')
->native(false)
->format('YYYY')
->label('Année')
->required(),
Forms\Components\DatePicker::make('year')
->native(false)
->format('YYYY')
->label('Année')
->required(),
Thanks for your help
4 replies
FFilament
Created by Hugo on 9/8/2023 in #❓┊help
How to use ListRecords table as headerWidget for another resource ?
Hi, I have an "ActivitySessionResource" resource and an "ActivityResource" resource, and I'd like to put the "ActivitySessionResource" table in the headerWidget of the "ActivityResource" resource. Can you help me ?
class ListActivities extends ListRecords
{
protected static string $resource = ActivityResource::class;

protected ?string $heading = 'Formations et Activités';

protected function getActions(): array
{
return [
Actions\CreateAction::make()
->label('Nouvelle Formation'),
];
}

protected function getHeaderWidgets(): array
{
return [
// put here ListActivitySessions table
];
}
}
class ListActivities extends ListRecords
{
protected static string $resource = ActivityResource::class;

protected ?string $heading = 'Formations et Activités';

protected function getActions(): array
{
return [
Actions\CreateAction::make()
->label('Nouvelle Formation'),
];
}

protected function getHeaderWidgets(): array
{
return [
// put here ListActivitySessions table
];
}
}
Thanks for your help
3 replies