Arrow
Arrow
FFilament
Created by Arrow on 1/9/2024 in #❓┊help
How to display infolist in a table column action with a relation record.
I want to display an infolist when a user clicks a column. I can easily do that using ViewAction. However, instead of the record iteself, I want to set the $record->customer as the infolist model. Is there something similar to fillForm for infolists?
TextColumn::make('name')
->action(function (HasTable $livewire, ?ExpiryReport $record) {
return ViewAction::make('View Customer')
->record($record->customer)
->infolist([
TextEntry::make('CRN')
TextEntry::make('NAME')
->label('Name'),
TextEntry::make('ADRS')
->label('Address'),
TextEntry::make('parentCrn')
->label('Parent'),
TextEntry::make('info.code')
->label('Code'),
])
->slideOver();
})
TextColumn::make('name')
->action(function (HasTable $livewire, ?ExpiryReport $record) {
return ViewAction::make('View Customer')
->record($record->customer)
->infolist([
TextEntry::make('CRN')
TextEntry::make('NAME')
->label('Name'),
TextEntry::make('ADRS')
->label('Address'),
TextEntry::make('parentCrn')
->label('Parent'),
TextEntry::make('info.code')
->label('Code'),
])
->slideOver();
})
5 replies
FFilament
Created by Arrow on 1/8/2024 in #❓┊help
Apply filament tab query filter to table on custom ViewRecord page
I have built a custom filament resource page (View type). I have added a separate table which get's its data using an api via sushi. I'm able to display the table and the tabs, but when I click on the tabs for filtering, it just refreshes the table, rather the applying the query. What I want is very similar to the filament's demo order page. orders
class ViewReport extends ViewRecord implements HasInfolists, HasTable, HasForms
{
use InteractsWithRecord;
use InteractsWithTable;
use ExposesTableToWidgets;
use HasTabs;

protected static string $resource = PortalsResource::class;
#[Url] public ?string $activeTab = null;

private static array $reportClasses = [
1 => FirstReport::class,
2 => SecondReport::class
];

public function table(Table $table): Table
{
$query = static::$reportClasses[$this->record->id]::query();
return $table
->query($query)
->columns([
TextColumn::make('crn'),
])
->bulkActions([
BulkAction::make("Renew")
]);
}
public function getTabs(): array
{
return [
null => Tab::make('All'),
'prepaid' => Tab::make()->query(fn ($query) => $query->where('isPrepaid', 1))
];
}
}
class ViewReport extends ViewRecord implements HasInfolists, HasTable, HasForms
{
use InteractsWithRecord;
use InteractsWithTable;
use ExposesTableToWidgets;
use HasTabs;

protected static string $resource = PortalsResource::class;
#[Url] public ?string $activeTab = null;

private static array $reportClasses = [
1 => FirstReport::class,
2 => SecondReport::class
];

public function table(Table $table): Table
{
$query = static::$reportClasses[$this->record->id]::query();
return $table
->query($query)
->columns([
TextColumn::make('crn'),
])
->bulkActions([
BulkAction::make("Renew")
]);
}
public function getTabs(): array
{
return [
null => Tab::make('All'),
'prepaid' => Tab::make()->query(fn ($query) => $query->where('isPrepaid', 1))
];
}
}
My view file
// view_report.blade.php
<div class="flex flex-col gap-y-6">
<x-filament-panels::resources.tabs />
{{ $this->table }}
</div>
</x-filament-panels::page>
// view_report.blade.php
<div class="flex flex-col gap-y-6">
<x-filament-panels::resources.tabs />
{{ $this->table }}
</div>
</x-filament-panels::page>
3 replies