Skip to content

Dynamic layout generation #1843

Answered by tabuna
sylzys asked this question in Q&A
Aug 19, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi @sylzys, classes for layers are not intended for construction, but you can move the logic to any other place and pass a list of classes to display, like this:

public function layout(): array
{
    $tabs = collect([
        Tab1::class,
        Tab2::class,
        Tab3::class,
    ])
        ->filter(function (string $class) {
            return $class !== Tab1::class;
        })
        ->toArray();
    
    return [
        Layout::tabs($tabs)
    ];
}

A slightly more complex example of construction, not for your case. But I must mention:

Personally, I try to avoid this definition, as I want to open the screen and see all of its definitions, not conditions.
For this, I prefer to defi…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sylzys
Comment options

@sylzys
Comment options

Answer selected by sylzys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants