mirror of
https://github.com/koel/koel
synced 2024-11-24 13:13:05 +00:00
26 lines
495 B
PHP
26 lines
495 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Models\Song;
|
|
use App\Services\HelperService;
|
|
|
|
class SongObserver
|
|
{
|
|
private $helperService;
|
|
|
|
public function __construct(HelperService $helperService)
|
|
{
|
|
$this->helperService = $helperService;
|
|
}
|
|
|
|
public function creating(Song $song): void
|
|
{
|
|
$this->setFileHashAsId($song);
|
|
}
|
|
|
|
private function setFileHashAsId(Song $song): void
|
|
{
|
|
$song->id = $this->helperService->getFileHash($song->path);
|
|
}
|
|
}
|