mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-11 02:36:42 +02:00
fix: clear cache when deleting podcast banner
This commit is contained in:
parent
209dfbd134
commit
99bb40b8bc
2 changed files with 30 additions and 0 deletions
|
|
@ -65,6 +65,18 @@ class MediaModel extends Model
|
|||
'updated_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* clear cache before update if by any chance, the podcast name changes, so will the podcast link
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $beforeUpdate = ['clearCache'];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $beforeDelete = ['clearCache'];
|
||||
|
||||
/**
|
||||
* Model constructor.
|
||||
*
|
||||
|
|
@ -166,4 +178,19 @@ class MediaModel extends Model
|
|||
|
||||
return $this->delete($media->id, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function clearCache(array $data): array
|
||||
{
|
||||
$mediaId = (is_array($data['id']) ? $data['id'][0] : $data['id']);
|
||||
|
||||
cache()
|
||||
->delete("media#{$mediaId}");
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue