koel/app/Observers/SongObserver.php

27 lines
495 B
PHP
Raw Normal View History

2018-08-29 07:58:46 +00:00
<?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
2018-10-19 14:33:04 +00:00
{
$this->setFileHashAsId($song);
}
private function setFileHashAsId(Song $song): void
2018-08-29 07:58:46 +00:00
{
$song->id = $this->helperService->getFileHash($song->path);
}
}