diff --git a/src/Illuminate/Filesystem/FilesystemManager.php b/src/Illuminate/Filesystem/FilesystemManager.php index f13d828a82bb..263ba3db040f 100644 --- a/src/Illuminate/Filesystem/FilesystemManager.php +++ b/src/Illuminate/Filesystem/FilesystemManager.php @@ -285,7 +285,13 @@ public function createScopedDriver(array $config) return $this->build(tap( is_string($config['disk']) ? $this->getConfig($config['disk']) : $config['disk'], - fn (&$parent) => $parent['prefix'] = $config['prefix'] + function (&$parent) use ($config) { + $parent['prefix'] = $config['prefix']; + + if (isset($config['visibility'])) { + $parent['visibility'] = $config['visibility']; + } + } )); } diff --git a/tests/Filesystem/FilesystemManagerTest.php b/tests/Filesystem/FilesystemManagerTest.php index ae58ef360b59..ef1eb632f92a 100644 --- a/tests/Filesystem/FilesystemManagerTest.php +++ b/tests/Filesystem/FilesystemManagerTest.php @@ -98,6 +98,40 @@ public function testCanBuildScopedDisks() } } + /** + * @requires OS Linux|Darwin + */ + public function testCanBuildScopedDisksWithVisibility() + { + try { + $filesystem = new FilesystemManager(tap(new Application, function ($app) { + $app['config'] = [ + 'filesystems.disks.local' => [ + 'driver' => 'local', + 'root' => 'to-be-scoped', + 'visibility' => 'public', + ], + ]; + })); + + $scoped = $filesystem->build([ + 'driver' => 'scoped', + 'disk' => 'local', + 'prefix' => 'path-prefix', + 'visibility' => 'private', + ]); + + $scoped->put('dirname/filename.txt', 'file content'); + + $this->assertEquals('private', $scoped->getVisibility('dirname/filename.txt')); + } finally { + unlink(__DIR__.'/../../to-be-scoped/path-prefix/dirname/filename.txt'); + rmdir(__DIR__.'/../../to-be-scoped/path-prefix/dirname'); + rmdir(__DIR__.'/../../to-be-scoped/path-prefix'); + rmdir(__DIR__.'/../../to-be-scoped'); + } + } + public function testCanBuildInlineScopedDisks() { try {