Skip to content

Commit

Permalink
Merge pull request #126 from lara-zeus/fix-library
Browse files Browse the repository at this point in the history
fix when library is empty
  • Loading branch information
atmonshi authored Jul 12, 2023
2 parents 2fe4881 + 7173c18 commit b8e13fc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Models/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Database\Factories\LibraryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection;
Expand Down Expand Up @@ -58,12 +59,12 @@ public function theFile(): ?string
return $this->file_path;
}

public function getFiles(): ?MediaCollection
public function getFiles(): MediaCollection|Collection
{
if (! $this->getMedia('library')->isEmpty()) {
return $this->getMedia('library');
}

return null;
return collect();
}
}

0 comments on commit b8e13fc

Please sign in to comment.