feat(episodes): replace soft delete with permanent delete

+ add constraint to prevent deleting an episode when published
This commit is contained in:
Ola Hneini 2022-05-05 15:48:16 +00:00 committed by Yassine Doghri
commit eb9ff522c2
20 changed files with 242 additions and 107 deletions

View file

@ -94,11 +94,6 @@ class EpisodeModel extends Model
*/
protected $returnType = Episode::class;
/**
* @var bool
*/
protected $useSoftDeletes = true;
/**
* @var bool
*/
@ -249,6 +244,18 @@ class EpisodeModel extends Model
return $found;
}
/**
* Returns number of episodes of a podcast
*/
public function getPodcastEpisodesCount(int $podcastId): int|string
{
return $this
->where([
'podcast_id' => $podcastId,
])
->countAllResults();
}
/**
* Returns the timestamp difference in seconds between the next episode to publish and the current timestamp Returns
* false if there's no episode to publish