Skip to content

Commit f457661

Browse files
fix user export
1 parent 784db67 commit f457661

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

app/Filament/Resources/UserResource/Actions/ExportAction.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,21 @@ protected function setUp(): void
3030
now()->format('Y_m_d-H_i_s'),
3131
Str::slug(UserResource::getPluralModelLabel()),
3232
))
33+
->fromTable()
3334
->modifyQueryUsing(function (Builder $query) {
3435
return $query
36+
->addSelect([
37+
'referrer',
38+
'id',
39+
'role',
40+
'name',
41+
'email',
42+
'email_verified_at',
43+
'created_at',
44+
'newsletter',
45+
'organization_id',
46+
'created_by',
47+
])
3548
->with([
3649
'donations' => fn ($q) => $q->select(['user_id', 'amount', 'status', 'created_at']),
3750
])
@@ -49,7 +62,7 @@ protected function setUp(): void
4962

5063
Column::make('role')
5164
->heading(__('user.labels.role'))->formatStateUsing(
52-
fn ($state) => $state->label()
65+
fn (User $record) => $record->role->label()
5366
),
5467

5568
Column::make('status')
@@ -77,6 +90,10 @@ protected function setUp(): void
7790
Column::make('referrer')
7891
->heading(__('user.labels.referrer')),
7992

93+
Column::make('donations_count')
94+
->formatStateUsing(fn (User $record) => $record->donations()->whereCharged()->count() ?? 0)
95+
->heading(__('user.labels.donations_count')),
96+
8097
Column::make('donations')
8198
->heading(__('user.labels.donations_sum'))
8299
->formatStateUsing(
@@ -85,8 +102,10 @@ protected function setUp(): void
85102
->sum('amount')
86103
),
87104

88-
Column::make('donations_count')
89-
->heading(__('user.labels.donations_count')),
105+
Column::make('comments_count')
106+
//TODO:: implement comments module and add this column
107+
->formatStateUsing(fn (User $record) => 'numarul de comentarii va aparea dupa implementarea modulului')
108+
->heading(__('user.labels.comments_count')),
90109

91110
Column::make('last_donation_date')
92111
->heading(__('user.labels.last_donation_date'))

0 commit comments

Comments
 (0)