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)


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
              ... 
            ]);
    }
}



how can i reuse TalentResource::getTalentProfile() inside JobApplicationResource. How do i pass the talent data inside the getTalentProfile() method.
Was this page helpful?