Add the ability to use a select list for template attributes

This commit is contained in:
2025-06-22 22:08:38 +10:00
parent 3ad4c446ea
commit 3bf97fc0d1
4 changed files with 53 additions and 2 deletions

View File

@@ -69,6 +69,19 @@ class Template
return collect($this->attributes->get($key));
}
/**
* Return an template attributes select options
*
* @param string $attribute
* @return Collection|NULL
*/
public function attributeOptions(string $attribute): Collection|NULL
{
return ($x=$this->attribute($attribute)?->get('options'))
? collect($x)->map(fn($item,$key)=>['id'=>$key,'value'=>$item])
: NULL;
}
/**
* If the attribute has been marked as read-only
*