Codesleeve\AssetPipeline\AssetPipelineController::file PHP Method

file() public method

Returns a file in the assets directory
public file ( $path ) : Illuminate\Support\Facades\Response
return Illuminate\Support\Facades\Response
    public function file($path)
    {
        $absolutePath = Asset::isJavascript($path);
        if ($absolutePath) {
            return $this->javascript($absolutePath);
        }
        $absolutePath = Asset::isStylesheet($path);
        if ($absolutePath) {
            return $this->stylesheet($absolutePath);
        }
        $absolutePath = Asset::isFile($path);
        if ($absolutePath) {
            $this->clientCacheForFile($absolutePath);
            return new BinaryFileResponse($absolutePath, 200);
        }
        App::abort(404);
    }

Usage Example

 public function file($path)
 {
     $path = preg_replace("/\\.\\./", "", $path);
     $format = "/([0-9a-zA-Z]+)\\.[0-9a-fA-F]+\\.(js|css)\$/";
     $path = preg_replace($format, '$1.$2', $path);
     // check for allowed extensions
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     if (in_array($ext, $this->allowedExtensions)) {
         return parent::file($path);
     }
     return abort(404);
 }