Skip to content

Commit

Permalink
feat: return key value pair from model
Browse files Browse the repository at this point in the history
  • Loading branch information
keeama13 authored and 64knl committed Nov 28, 2023
1 parent fcf9a75 commit b3182e8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Services/Assets/Components/ComponentModelSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ public function getAutoLayoutClass(): ?AbstractLayout
{
$inputDropdown = new LayoutInputDropdown($this->assetItem->internal, $this->assetItem->name);

$server_properties = $this->properties();

$items = $this->getModels();

foreach ($items as $item) {
foreach ($items as $key => $value) {
$inputDropdown->addItem(
$item->id,
$item->{$server_properties->methodName}()
$key,
$value,
);
}

Expand All @@ -34,16 +32,16 @@ public function validate($newValue): bool

public function getTableOverviewContent(): LayoutTableColumn
{
$value = $this->properties()->selectedModel::find($this->getCurrentValue());
$value = $this->properties()->selectedModel::{$this->properties()->methodName}($this->getCurrentValue(), true);

$display = ($value) ? $value->{$this->properties()->methodName}() : '-';
$display = ($value) ? $value : '-';

return new LayoutTableColumn($display, $this->type);
}

private function getModels()
{
return $this->properties()->selectedModel::all();
return $this->properties()->selectedModel::{$this->properties()->methodName}($this->getCurrentValue());
}

/**
Expand Down

0 comments on commit b3182e8

Please sign in to comment.