src/Concerns/Selection.php
protected function getSelectedValue(?string $value, $selected): ?string
    {
        $selection = $selected instanceof Arrayable ? $selected->toArray() : $selected;

        if (\is_array($selection)) {
            if (\in_array($value, $selection, true) || \in_array((string) $value, $selection, true)) {
                return 'selected';
            } elseif ($selected instanceof Collection) {
                return $selected->contains($value) ? 'selected' : null;
            }

            return null;
        }

        if (\is_int($value) && \is_bool($selected)) {
            return (bool) $value === $selected;
        }

        return ((string) $value === (string) $selected) ? 'selected' : null;
    }
protected function getSelectedValue(?string $value, $selected): ?string
    {
        $selection = $selected instanceof Arrayable ? $selected->toArray() : $selected;

        if (\is_array($selection)) {
            if (\in_array($value, $selection, true) || \in_array((string) $value, $selection, true)) {
                return 'selected';
            } elseif ($selected instanceof Collection) {
                return $selected->contains($value) ? 'selected' : null;
            }

            return null;
        }

        if (\is_int($value) && \is_bool($selected)) {
            return (bool) $value === $selected;
        }

        return ((string) $value === (string) $selected) ? 'selected' : null;
    }
Determine if the value is selected.

@param  string|null $value
@param  string|array|\Illuminate\Contracts\Support\Arrayable|bool|null  $selected

@return string|null