Can you use IconColumn without database column

Hello, I'm using Breezy and I have a question about displaying the status of two-factor authentication (2FA) for users. In the documentation, I noticed that columns are created using database column names, but I'd like to use the breezy function to determine if a user has enabled 2FA or not, because as far as i noticed there is no database field for that. This is the code i have so far, but did not work:
IconColumn::make('2fa' )->icons(fn (User $user) => $user->hasEnabledTwoFactor() ? ['heroicon-o-lock-closed'] : ['heroicon-o-lock-open']),
IconColumn::make('2fa' )->icons(fn (User $user) => $user->hasEnabledTwoFactor() ? ['heroicon-o-lock-closed'] : ['heroicon-o-lock-open']),
Solution:
Maybe something like this: ```php IconColumn::make('2fa') ->getStateUsing(fn (User $record) => $record->hasEnabledTwoFactor()) ->trueIcon('heroicon-o-lock-closed')...
Jump to solution
2 Replies
Solution
Patrick Boivin
Patrick Boivin14mo ago
Maybe something like this:
IconColumn::make('2fa')
->getStateUsing(fn (User $record) => $record->hasEnabledTwoFactor())
->trueIcon('heroicon-o-lock-closed')
->falseIcon('heroicon-o-lock-open'),
IconColumn::make('2fa')
->getStateUsing(fn (User $record) => $record->hasEnabledTwoFactor())
->trueIcon('heroicon-o-lock-closed')
->falseIcon('heroicon-o-lock-open'),
Kyrill71
Kyrill71OP14mo ago
Thank you that works.
Want results from more Discord servers?
Add your server