Null handling of soft deleted tracks for favourites page

This commit is contained in:
Alex Ramirez 2023-11-12 22:37:48 -08:00
parent d054bb4a34
commit 8f71b408ef

View file

@ -91,8 +91,11 @@ class Favourite extends Model
} else {
if ($this->playlist_id) {
return $this->playlist;
} // no resource - this should never happen under real circumstances
}
else {
// No resource
// In this case, either the resource was
// soft-deleted or something else occurred.
return null;
}
}
@ -101,6 +104,11 @@ class Favourite extends Model
public function getTypeAttribute()
{
return get_class($this->resource);
// As of PHP 7.2, get_class is picky about null args
if ($resource = $this->resource) {
return get_class($resource);
} else {
return null;
}
}
}