name => (object) [ // 'label' => trans('front.search.title'), // 'route' => '/recherche?texte=LDC', // ] // ]); // return collect($dataKeyValue) // ->reject(fn($item) => is_null($item->label) || is_null($item->route)) // ->map(function ($item, $key) { // $targetEnum = collect(self::cases()) // ->first(fn($enum) => $enum->name === $key); // return (object) [ // 'label' => ucfirst($item->label), // 'value' => $targetEnum->value, // 'route' => $item->route, // ]; // }) // ->when(!is_null($callback), fn ($collection) => $collection->filter($callback)) // ->values() // ->toArray(); } /** * Get the url of a given enum value. * * @param integer $value * @return string|null */ public static function getRoute(int $value): ?string { $collect = collect(self::getRoutes(fn ($route) => $route->value == $value)); return $collect->isEmpty() ? null : $collect->first()->route; } }