engelsystem/src/Routing/UrlGenerator.php

26 lines
565 B
PHP
Raw Normal View History

<?php
namespace Engelsystem\Routing;
2018-03-31 05:19:49 +02:00
class UrlGenerator implements UrlGeneratorInterface
{
/**
* @param string $path
* @param array $parameters
* @return string
*/
2017-09-20 01:09:11 +02:00
public function to($path, $parameters = [])
{
$path = '/' . ltrim($path, '/');
2017-08-31 17:30:54 +02:00
$request = app('request');
$uri = $request->getUriForPath($path);
if (!empty($parameters) && is_array($parameters)) {
$parameters = http_build_query($parameters);
$uri .= '?' . $parameters;
}
return $uri;
}
}