Repository: laravel/framework (php)

Issue:
Scoped Storage drivers returning incorrect url with url() function
<!-- DO NOT THROW THIS AWAY -->
<!-- Fill out the FULL versions with patch versions -->

- Laravel Version: 9.32.0
- PHP Version: 8.1.4
- Database Driver & Version:

### Description:
Scoped storage driver cannot be used out of the box as "league/flysystem-path-prefixing": "^3.3", is in require-dev and not in require. So it isn't installed on default laravel installation.

Solution: Update the doc to include installation of driver when using scoped drivers.
```
composer require league/flysystem-path-prefixing
```

Scoped drivers on local not prefixing the prefix-path to base disk path in Storage::url() function. So it returns incorrect url for scoped local drivers.
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Filesystem/FilesystemAdapter.php#L621
```
        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL') . '/storage',
            'visibility' => 'public',
            'throw' => false,
        ],

        'public-blogs' => [
            'driver' => 'scoped',
            'disk' => 'public',
            'prefix' => 'blogs',
        ],

```
```
    public function url($path)
    {
        $adapter = $this->adapter;

        if (method_exists($adapter, 'getUrl')) {
            return $adapter->getUrl($path);
        } elseif (method_exists($this->driver, 'getUrl')) {
            return $this->driver->getUrl($path);
        } elseif ($adapter instanceof FtpAdapter || $adapter instanceof SftpAdapter) {
            return $this->getFtpUrl($path);
        } elseif ($adapter instanceof LocalAdapter) {
            return $this->getLocalUrl($path);
        } else {
            throw new RuntimeException('This driver does not support retrieving URLs.');
        }
    }
```
### Steps To Reproduce:
Default Laravel installation v.9.30^
<!-- If possible, please provide a GitHub repository to demonstrate your issue -->
<!-- laravel new bug-report --github="--public" -->


Pull request description:
Fixed #44327: use prefix for url when generating url for scoped disk
The S3 adapter already had its own prefixing, the local prefixing for the generated URL is added in this PR. This fixes #44327.


Patch:
diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php
index 40d0234db8..91ea802592 100644
--- a/src/Illuminate/Filesystem/FilesystemAdapter.php
+++ b/src/Illuminate/Filesystem/FilesystemAdapter.php
@@ -620,6 +620,10 @@ public function writeStream($path, $resource, array $options = [])
      */
     public function url($path)
     {
+        if (isset($this->config['prefix'])) {
+            $path = $this->concatPathToUrl($this->config['prefix'], $path);
+        }
+
         $adapter = $this->adapter;
 
         if (method_exists($adapter, 'getUrl')) {


Test patch:
diff --git a/tests/Filesystem/FilesystemAdapterTest.php b/tests/Filesystem/FilesystemAdapterTest.php
index 8fe056078a..e0d045d38e 100644
--- a/tests/Filesystem/FilesystemAdapterTest.php
+++ b/tests/Filesystem/FilesystemAdapterTest.php
@@ -564,4 +564,11 @@ public function testProvidesTemporaryUrlsForAdapterWithoutTemporaryUrlSupport()
 
         $this->assertFalse($filesystemAdapter->providesTemporaryUrls());
     }
+
+    public function testPrefixesUrls()
+    {
+        $filesystemAdapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['url' => 'https://example.org/', 'prefix' => 'images']);
+
+        $this->assertEquals('https://example.org/images/picture.jpeg', $filesystemAdapter->url('picture.jpeg'));
+    }
 }