ldc-groupe/app/Helpers/RouteHelper.php

26 lines
772 B
PHP

<?php
namespace App\Helpers;
use Uwil\LaravelCommon\Controllers\Controller;
class RouteHelper extends Controller
{
/**
* Check if a route name exists and return its URL.
*
* This method verifies if the specified route name is registered in Laravel.
* If the route exists, it returns the corresponding URL using the route helper.
* Otherwise, it returns a "#" as a fallback.
*
* @param string $routeName The name of the route to check.
* @return string The route URL if it exists, or "#" otherwise.
*/
public static function routeNameChecker(string $routeName): string
{
if (\Illuminate\Support\Facades\Route::has($routeName)) {
return route($routeName);
}
return "#";
}
}