ImI'm trying to cleanupclean-up the assets in a specific folder that arentaren't being used at all, ie arenti.e. aren't related to anything.
I got the list okO.K. just using this
$assets = Asset::find()->volume('artists')->kind('image')->limit(50000)->ids();
$assetsToDelete = [];
foreach($assets as $asset) {
$results = (new Query())
->select(['id'])
->from(['{{%relations}}'])
->where(['targetId' => $asset])
->orWhere(['sourceId' => $asset])
->all();
if (!count($results)) {
$assetsToDelete[] = $asset;
}
}
return $this->asJson($assetsToDelete);
rightRight now imI'm just returning all the ids in an array but imI'm hoping to find a command to delete the element AND delete the stored asset on the server
Any ideas?