Dynamic view when using ViewEntry possible?

In an infolist I want to load a view based on "transaction->account->type". My current working solution ist this:

return $infolist ->schema([ ViewEntry::make('paypal') ->visible(function (Transaction $transaction) { return $transaction->account->type == 'paypal'; }) ->view('filament.infolists.transaction.paypal'), ViewEntry::make('bank') ->visible(function (Transaction $transaction) { return $transaction->account->type == 'bank'; }) ->view('filament.infolists.transaction.bank'), ViewEntry::make('cash') ->visible(function (Transaction $transaction) { return $transaction->account->type == 'cash'; }) ->view('filament.infolists.transaction.cash') ]);

is there a better way?

an other alternative may is to load the final view (paypal, bank or cash) in a base view ...
Was this page helpful?