ldc-groupe/app/Enums/StaticRoutesEnum.php
2026-02-19 14:06:28 +01:00

56 lines
1.7 KiB
PHP

<?php
namespace App\Enums;
use App\Enums\Contact\ContactFormType;
use Uwil\LaravelCommon\Traits\Enums\BaseEnum;
enum StaticRoutesEnum: int
{
use BaseEnum;
// Set all cases for each static routes.
/**
* Get array of each route with his matching value.
*
* @param callable|null $callback
* @return array
*/
public static function getRoutes(?callable $callback = null)
{
// $dataKeyValue = array_merge([], [
// self::search->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;
}
}