singleloginsystem/app/Livewire/Concerns/Choices/WithSearchableChoices.php
= e791c08ce1 Feat: (UI) Replace connected-app creation with modular OIDC service and components
- Removed the old `connected-apps.create` implementation and components, simplifying the codebase.
- Introduced modular OIDC integration using reusable components and traits, such as `WithSearchableChoices` and `WithRepeaterFields`.
- Added `StoreOIDCAppForm` for handling OpenID Connect app-specific fields and validation.
- Updated `choices.blade.php` and related components to leverage configuration-driven, dynamic multi-select functionality.
- Updated routes to support new OIDC app creation under distinct connection protocol namespaces.
- Enhanced app creation flow with support for dynamic fields like URIs (`repeater-input`) and scoped user roles.
2026-06-18 09:48:07 +00:00

54 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Livewire\Concerns\Choices;
use InvalidArgumentException;
trait WithSearchableChoices
{
/** @var array<string, array<int, mixed>> */
public array $choicesSearchable = [];
public function selectAllChoice(string $key): void
{
$field = $this->resolveChoiceField($key);
data_set($this, $field->formPath, ($field->allIds)());
$this->searchChoice($key);
$field->after?->__invoke();
}
protected function resolveChoiceField(string $key): ChoiceField
{
return $this->choiceFields()[$key]
?? throw new InvalidArgumentException("Unknown choice field [{$key}].");
}
/** @return array<string, ChoiceField> */
abstract protected function choiceFields(): array;
/**
* @param string $key this should be one of the top level array key, defined in choiceFields()
* @param string $value this is the value to search for
*/
public function searchChoice(string $key, string $value = ''): void
{
$field = $this->resolveChoiceField($key);
$this->choicesSearchable[$key] = ($field->search)($value);
}
public function clearChoice(string $key): void
{
$field = $this->resolveChoiceField($key);
data_set($this, $field->formPath, []);
$field->after?->__invoke();
}
}