orchidsoftware / orchidsoftware/platform

Multiple Cards

Open
#1,639 1 comment 0 reactions 1 assignee View on GitHub

@tabuna is already working on this.

Since Mar 29, 2021.

Dominant language
PHP
Stars
4.8k
Forks
662
Avg merge
1d 9h
Merged PRs (30d)
7

Description

Is your feature request related to a problem? Please describe.
This is more of a call for help than a feature request.

I read the documentation and looked through the issues but I can't seem to understand how to access query data or display multiple cards in layout().

I have a card presenter on my Service model and I'm trying to display a card collection.
Basically display a card for every Service record on the Screen.

Describe the solution you'd like

It would be nice if I just could pass an array of Cardable elements and have them displayed.

public function query(): array
{
    return [
        'services' => Service::all()->presenter(),
    ];
}

public function layout(): array
{
    return [
        new Card('services', [
                Link::make('Edit')->route('platform.service.edit', 'service.id'),
        ]),
    ];
}

Would this even work?

Describe alternatives you've considered

This is my current working version, is there a better way to do this?

public function query(): array
{
    $this->services = Service::all();
        
    $out = [];
    foreach ($this->services as $service)
    {
        $out[$service->name] = $service->presenter();
    }

    return $out;
}

public function layout(): array
{
    $cards = [];

    foreach ($this->services as $service)
    {
        $cards[$service->name] = new Card($service->name, [
            Link::make('Edit')->route('platform.service.edit', $service->id)
        ]);
    }
    
    return $cards;
}

Additional context
I'm having a hard time understanding how to add layout elements dynamically.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.