F
Filament15mo ago
lazydog

Custom Page

I've added a custom page to my EventResource, specifically the
```
public static function getPages(): array
{
return [
'index' => Pages\ListEvents::route('/'),
'create' => Pages\CreateEvent::route('/create'),
'view' => Pages\ViewEvent::route('/{record}'),
'edit' => Pages\EditEvent::route('/{record}/edit'),
'take-attendance' => Pages\TakeAttendance::route('/{record}/take-attendance'),
];
}
```
public static function getPages(): array
{
return [
'index' => Pages\ListEvents::route('/'),
'create' => Pages\CreateEvent::route('/create'),
'view' => Pages\ViewEvent::route('/{record}'),
'edit' => Pages\EditEvent::route('/{record}/edit'),
'take-attendance' => Pages\TakeAttendance::route('/{record}/take-attendance'),
];
}
I implemented the HasInfolist
class TakeAttendance extends Page implements HasInfolists
{
use InteractsWithRecord;

public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->record(Event::first())
->schema([]);
}
class TakeAttendance extends Page implements HasInfolists
{
use InteractsWithRecord;

public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->record(Event::first())
->schema([]);
}
When I browse this userl admin/events/1/take-attendance , how can I get the Event data that has an ID of 1 and put it in my
->record(SpecificEvent Here)
->record(SpecificEvent Here)
So that I can use it in viewing data
Solution:
static methods are for resources to be retrieved by the "page" class later. If you declare directly in the page class, it should be public function infolist(Infolist $infolist): Infolist
Jump to solution
6 Replies
lazydog
lazydogOP15mo ago
I can't use
$this
$this
inside infolist method
IndomieRendang
IndomieRendang15mo ago
why static?
lazydog
lazydogOP15mo ago
I just copied it from my main resource. What should be?
Solution
IndomieRendang
IndomieRendang15mo ago
static methods are for resources to be retrieved by the "page" class later. If you declare directly in the page class, it should be public function infolist(Infolist $infolist): Infolist
lazydog
lazydogOP15mo ago
ohh nice! that's new to me. It works. thanks for the knowledge 🙂
IndomieRendang
IndomieRendang15mo ago
yepp... that also applies for other methods like form(), table(), etc

Did you find this page helpful?