Make sure files are createed with the correct folder id

parent 62625d47
......@@ -57,7 +57,7 @@ class EloquentFileRepository extends EloquentBaseRepository implements FileRepos
'extension' => substr(strrchr($fileName, '.'), 1),
'mimetype' => $file->getClientMimeType(),
'filesize' => $file->getFileInfo()->getSize(),
'folder_id' => 0,
'folder_id' => $parentId,
];
event($event = new FileIsCreating($data));
......
......@@ -230,6 +230,7 @@ class EloquentFileRepositoryTest extends MediaTestCase
$this->assertCount(2, $this->file->all());
$this->assertEquals('/assets/media/my-folder/my-file.jpg', $file->path->getRelativeUrl());
$this->assertEquals($folder->id, $file->folder_id);
}
/** @test */
......@@ -242,6 +243,7 @@ class EloquentFileRepositoryTest extends MediaTestCase
$file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('my-file.jpg'), $nestedFolder->id);
$this->assertEquals('/assets/media/my-folder/nested-folder/my-file.jpg', $file->path->getRelativeUrl());
$this->assertEquals($nestedFolder->id, $file->folder_id);
}
private function createFile($fileName = 'random/name.jpg')
......
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