better file password implementation

This commit is contained in:
2024-04-25 18:40:40 +10:00
parent c702253837
commit 39609edc9e
6 changed files with 19 additions and 5 deletions

View File

@@ -10,7 +10,11 @@ trait HasFiles
{
public function files($collection = null)
{
// return $this->morphToMany(Media::class, 'mediable')
// ->wherePivot('collection', $collection);
return $this->morphToMany(Media::class, 'mediable')
->selectRaw("*, CASE WHEN password IS NULL THEN NULL ELSE 'yes' END AS password")
->wherePivot('collection', $collection);
}