You can use the URL facade which lets you do calls to the URL generator
So you can do:
URL::to('/');
You can also use the application container:
$app->make('url')->to('/');
$app['url']->to('/');
App::make('url')->to('/');
Or inject the UrlGenerator:
<?php
namespace VendorYourClassNamespace;
use IlluminateRoutingUrlGenerator;
class Classname
{
protected $url;
public function __construct(UrlGenerator $url)
{
$this->url = $url;
}
public function methodName()
{
$this->url->to('/');
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…