mirror of
https://code.castopod.org/adaures/castopod
synced 2025-05-24 11:02:00 +00:00
fix: clear cache when deleting podcast banner
This commit is contained in:
parent
209dfbd134
commit
99bb40b8bc
@ -65,6 +65,18 @@ class MediaModel extends Model
|
|||||||
'updated_by',
|
'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.
|
* Model constructor.
|
||||||
*
|
*
|
||||||
@ -166,4 +178,19 @@ class MediaModel extends Model
|
|||||||
|
|
||||||
return $this->delete($media->id, true);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,6 +381,9 @@ class PodcastController extends BaseController
|
|||||||
->withInput()
|
->withInput()
|
||||||
->with('errors', $mediaModel->errors());
|
->with('errors', $mediaModel->errors());
|
||||||
}
|
}
|
||||||
|
(new PodcastModel())->clearCache([
|
||||||
|
'id' => $this->podcast->id,
|
||||||
|
]);
|
||||||
|
|
||||||
// remove banner url from actor
|
// remove banner url from actor
|
||||||
$actor = (new ActorModel())->getActorById($this->podcast->actor_id);
|
$actor = (new ActorModel())->getActorById($this->podcast->actor_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user