FilamentF
Filamentβ€’10mo ago
lbar

Exporter duplicate rows for relations

Hi, i'm working with the exporter. I need to to duplicate the record of the table exported, one for every relation of the record (it's a registration->members relation so 1 registration with N members, with a pivot table).
It's there a way to duplicate the exported record in that way?

Example (pseudo code):
registration_id, registration_transaction_id, member_firstname, member_lastname 
1, 123, john, doe
1, 123, jane, doe
2, 345, may, jane
2, 345, july, crockett
...
...
...

can't find anything online, and LLM goes crazy very bad with that one... πŸ˜•
ty
Solution
public static function modifyQuery(Builder $query): Builder
{
    $query->join('registration_member', 'registrations.id', '=', 'registration_member.registration_id')
          ->join('members', 'registration_member.member_id', '=', 'members.id')
          ->select(
              'registrations.id',
              'registrations.competition_name',
              'registrations.transaction_id',
              'members.firstname',
              'members.lastname'
          );

    return $query;
}
Was this page helpful?