How to share a resource infolist

Let me explain the relationship structure and the current issue: Resource Relationships: - JobPostResource is the parent resource - JobApplicationResource is a child resource of JobPostResource (indicated by public static string $parentResource = JobPostResource::class;) - OutsourcingListResource (Talent) is related to JobApplication through a relationship Data Flow: - A Job Post can have multiple Job Applications - Each Job Application is associated with one Talent (OutsourcingList) - The relationship path is: JobPost -> JobApplication -> Talent Relationship Structure:
JobPost
└── JobApplications (has many)
└── Talent (belongs to)

JobPost
└── JobApplications (has many)
└── Talent (belongs to)

Current Issue: - In the infolist, we're trying to display Talent information within a Job Application like $infolist->getRecord()->talent) by reusing TalentResources::infolist() inside JobApplicationResource::infolist()
class TalentResource extends Resource
{
public static function getTalentProfile()
{
return \Filament\Infolists\Components\Section::make([
TextEntry::make('fullname'),
TextEntry::make('email'),
TextEntry::make('phone'),
// ...... (5+ entries)
]);
}
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
self::getTalentProfile(),
]);
}
}

class JobApplicationResource extends Resource
{
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
TextEntry::make('status')->badge(),
TextEntry::make('talent.fullname'), // works
...
]);
}
}
class TalentResource extends Resource
{
public static function getTalentProfile()
{
return \Filament\Infolists\Components\Section::make([
TextEntry::make('fullname'),
TextEntry::make('email'),
TextEntry::make('phone'),
// ...... (5+ entries)
]);
}
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
self::getTalentProfile(),
]);
}
}

class JobApplicationResource extends Resource
{
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
TextEntry::make('status')->badge(),
TextEntry::make('talent.fullname'), // works
...
]);
}
}
how can i reuse TalentResource::getTalentProfile() inside JobApplicationResource. How do i pass the talent data inside the getTalentProfile() method.
1 Reply
Matthew
Matthew2w ago
3 approaches are to either build quite a complicated array building function, and loop your data in. Using mainly placeHolders and the like. Or, use the relationship and repeatable entries. Or, you could put a table widget in with your talent details.

Did you find this page helpful?