show data based on data in database

i want to show data based on data in database example: [ 0 => public 1 => private ]
9 Replies
Vp
Vp17mo ago
Can you be more specific, in table or select? or where do you want to check this condition?
shissaaa
shissaaaOP17mo ago
if have email verified at then just show verified else show not verified
Vp
Vp17mo ago
In the resource you can check like below
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->whereNotNull('email_verified_at');
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->whereNotNull('email_verified_at');
}
Or you can provide filter which will show "email_verified" only, and provide options to show all
Dennis Koch
Dennis Koch17mo ago
Have a look at Filters in the docs.
shissaaa
shissaaaOP17mo ago
I mean it will show all data. but it will show based on data in database when null, will show not verified. when have datetime, will show verified can you help me
Dennis Koch
Dennis Koch17mo ago
You can use a BooleanColumn and getStateUsing()
shissaaa
shissaaaOP17mo ago
oh, thank you so much
Noxo
Noxo17mo ago
TextColumn::make('email_verified_at')
->getStateUsing(fn ($record) => is_null($record->email_verified_at) ? 'Not verified' : 'Verified')
->badge(),
TextColumn::make('email_verified_at')
->getStateUsing(fn ($record) => is_null($record->email_verified_at) ? 'Not verified' : 'Verified')
->badge(),
shissaaa
shissaaaOP17mo ago
thank you so much

Did you find this page helpful?