koel/app/Observers/SongObserver.php

27 lines
453 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\Helper;
2018-08-29 07:58:46 +00:00
class SongObserver
{
private Helper $helper;
2018-08-29 07:58:46 +00:00
public function __construct(Helper $helper)
2018-08-29 07:58:46 +00:00
{
$this->helper = $helper;
2018-08-29 07:58:46 +00:00
}
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->helper->getFileHash($song->path);
2018-08-29 07:58:46 +00:00
}
}