remove return type hint, can return null as well

parent 956422fe
...@@ -13,9 +13,9 @@ class EloquentFolderRepository extends EloquentBaseRepository implements FolderR ...@@ -13,9 +13,9 @@ class EloquentFolderRepository extends EloquentBaseRepository implements FolderR
/** /**
* Find a folder by its ID * Find a folder by its ID
* @param int $folderId * @param int $folderId
* @return File * @return File|null
*/ */
public function findFolder(int $folderId): File public function findFolder(int $folderId)
{ {
return $this->model->where('is_folder', 1)->where('id', $folderId)->first(); return $this->model->where('is_folder', 1)->where('id', $folderId)->first();
} }
...@@ -44,8 +44,9 @@ class EloquentFolderRepository extends EloquentBaseRepository implements FolderR ...@@ -44,8 +44,9 @@ class EloquentFolderRepository extends EloquentBaseRepository implements FolderR
{ {
if (array_key_exists('parent_id', $data)) { if (array_key_exists('parent_id', $data)) {
$parent = $this->findFolder($data['parent_id']); $parent = $this->findFolder($data['parent_id']);
if ($parent !== null) {
return $parent->path->getRelativeUrl() . '/' . str_slug(array_get($data, 'name')); return $parent->path->getRelativeUrl() . '/' . str_slug(array_get($data, 'name'));
}
} }
return config('asgard.media.config.files-path') . str_slug(array_get($data, 'name')); return config('asgard.media.config.files-path') . str_slug(array_get($data, 'name'));
......
...@@ -10,7 +10,7 @@ interface FolderRepository extends BaseRepository ...@@ -10,7 +10,7 @@ interface FolderRepository extends BaseRepository
/** /**
* Find a folder by its ID * Find a folder by its ID
* @param int $folderId * @param int $folderId
* @return File * @return File|null
*/ */
public function findFolder(int $folderId) : File; public function findFolder(int $folderId);
} }
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