// 1) Combine labels & icons in one array: $elementTypes = [ 'one_image' => ['label' => 'One Image', 'icon' => 'heroicon-m-photo'], 'text' => ['label' => 'Text', 'icon' => 'heroicon-m-document-text'], 'quote' => ['label' => 'Quote', 'icon' => 'heroicon-m-chat-bubble-bottom-center-text'], 'h2' => ['label' => 'Heading 2', 'icon' => 'heroicon-m-hashtag'],// and others... ]; $actions = []; foreach($elementTypes as $key => $type) { $actions[] = Action::make('addElement_{$key}') ->label($elementTypes[$key]['label']) ->icon(fn (Get $get) => $elementTypes[$key]['icon'] ?? 'heroicon-m-plus') ->action(function (Set $set, Get $get) use ($elementTypes, $key) { $items = $get('elements') ?? []; $type = $key; $items[] = [ 'type' => $type, 'value' => null, 'sort' => count($items), ]; $set('elements', $items); $set('newElementType', null); $key = null; }); }