Illuminate\Routing\UrlGenerator::asset PHP Method

asset() public method

Generate the URL to an application asset.
public asset ( string $path, boolean | null $secure = null ) : string
$path string
$secure boolean | null
return string
    public function asset($path, $secure = null)
    {
        if ($this->isValidUrl($path)) {
            return $path;
        }
        // Once we get the root URL, we will check to see if it contains an index.php
        // file in the paths. If it does, we will remove it since it is not needed
        // for asset paths, but only for routes to endpoints in the application.
        $root = $this->getRootUrl($this->getScheme($secure));
        return $this->removeIndex($root) . '/' . trim($path, '/');
    }

Usage Example

 /**
  * {@inheritdoc}
  * @throws \Plank\Mediable\Exceptions\MediaUrlException If media's disk is not publicly accessible
  */
 public function getUrl()
 {
     $path = $this->getPublicPath();
     $url = $this->getDiskConfig('url');
     if ($url) {
         if ($this->isInWebroot()) {
             $path = $this->media->getDiskPath();
         }
         return rtrim($url, '/') . '/' . trim($path, '/');
     }
     return $this->url->asset($path);
 }
All Usage Examples Of Illuminate\Routing\UrlGenerator::asset