orchidsoftware / orchidsoftware/platform
Multiple Cards
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.