Handle local filesystem with public prefix

parent e548ba18
...@@ -19,7 +19,16 @@ class CreateFolderOnDisk ...@@ -19,7 +19,16 @@ class CreateFolderOnDisk
public function handle(FolderWasCreated $event) public function handle(FolderWasCreated $event)
{ {
$this->filesystem->disk($this->getConfiguredFilesystem())->makeDirectory($event->folder->path->getRelativeUrl()); $this->filesystem->disk($this->getConfiguredFilesystem())->makeDirectory($this->getDestinationPath($event->folder->path->getRelativeUrl()));
}
private function getDestinationPath($path)
{
if ($this->getConfiguredFilesystem() === 'local') {
return basename(public_path()) . $path;
}
return $path;
} }
/** /**
......
...@@ -35,7 +35,7 @@ final class EloquentFolderRepositoryTest extends MediaTestCase ...@@ -35,7 +35,7 @@ final class EloquentFolderRepositoryTest extends MediaTestCase
/** @test */ /** @test */
public function it_can_create_a_folder_in_database() public function it_can_create_a_folder_in_database()
{ {
$folder = $this->folder->create(['name' => 'My Folder']); $folder = $this->folder->create(['name' => 'My Folder', 'parent_id' => 0]);
$this->assertCount(1, $this->folder->all()); $this->assertCount(1, $this->folder->all());
$this->assertEquals('My Folder', $folder->filename); $this->assertEquals('My Folder', $folder->filename);
......
...@@ -65,6 +65,6 @@ abstract class MediaTestCase extends TestCase ...@@ -65,6 +65,6 @@ abstract class MediaTestCase extends TestCase
$app['config']->set('app.url', 'http://localhost'); $app['config']->set('app.url', 'http://localhost');
$app['config']->set('filesystems.disks.local.url', 'http://localhost'); $app['config']->set('filesystems.disks.local.url', 'http://localhost');
$app['config']->set('filesystems.disks.local.visibility', 'public'); $app['config']->set('filesystems.disks.local.visibility', 'public');
$app['config']->set('filesystems.disks.local.root', public_path()); $app['config']->set('filesystems.disks.local.root', base_path());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment