pelican-panel-mirror/app/Services/Nests/NestUpdateService.php
2024-03-12 22:39:16 -04:00

31 lines
724 B
PHP

<?php
namespace App\Services\Nests;
use App\Contracts\Repository\NestRepositoryInterface;
class NestUpdateService
{
/**
* NestUpdateService constructor.
*/
public function __construct(protected NestRepositoryInterface $repository)
{
}
/**
* Update a nest and prevent changing the author once it is set.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws \App\Exceptions\Repository\RecordNotFoundException
*/
public function handle(int $nest, array $data): void
{
if (!is_null(array_get($data, 'author'))) {
unset($data['author']);
}
$this->repository->withoutFreshModel()->update($nest, $data);
}
}