mirror of
https://github.com/koel/koel
synced 2024-12-27 13:03:06 +00:00
30 lines
498 B
PHP
30 lines
498 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Models\Album;
|
|
use Exception;
|
|
use Illuminate\Log\Logger;
|
|
|
|
class AlbumObserver
|
|
{
|
|
private $logger;
|
|
|
|
public function __construct(Logger $logger)
|
|
{
|
|
$this->logger = $logger;
|
|
}
|
|
|
|
public function deleted(Album $album): void
|
|
{
|
|
if (!$album->has_cover) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
unlink($album->cover_path);
|
|
} catch (Exception $e) {
|
|
$this->logger->error($e);
|
|
}
|
|
}
|
|
}
|