for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Thinktomorrow\AssetLibrary\Application;
use Thinktomorrow\AssetLibrary\Asset;
use Thinktomorrow\AssetLibrary\HasAsset;
use Thinktomorrow\AssetLibrary\Exceptions\FileNotAccessibleException;
class DeleteAsset
{
/**
* Removes an asset completely.
*
* @param $ids
*/
public function delete($ids): void
if (is_array($ids)) {
foreach ($ids as $id) {
self::remove($id);
Thinktomorrow\AssetLibra...n\DeleteAsset::remove()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
self::/** @scrutinizer ignore-call */
remove($id);
}
} else {
if (! $ids) {
return;
self::remove($ids);
public function remove($id)
if (! $id) {
return false;
$asset = Asset::find($id)->first();
$media = $asset->media;
foreach ($media as $file) {
if (! is_file(public_path($file->getUrl())) || ! is_writable(public_path($file->getUrl()))) {
throw new FileNotAccessibleException();
$asset->delete();
* Removes all assets completely.
public function deleteAll(HasAsset $model): void
$model->assetRelation->each->delete();
assetRelation
Thinktomorrow\AssetLibrary\HasAsset
instanceof