Files

48 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
2017-09-25 21:43:01 -05:00
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
2017-09-25 21:43:01 -05:00
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
2017-10-06 23:57:53 -05:00
namespace Pterodactyl\Services\Nests;
2017-10-06 23:57:53 -05:00
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
2017-10-06 23:57:53 -05:00
class NestUpdateService
{
/**
2017-10-06 23:57:53 -05:00
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
protected $repository;
/**
2017-10-06 23:57:53 -05:00
* NestUpdateService constructor.
*
2017-10-06 23:57:53 -05:00
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
*/
2017-10-06 23:57:53 -05:00
public function __construct(NestRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
2017-10-06 23:57:53 -05:00
* Update a nest and prevent changing the author once it is set.
*
2017-10-06 23:57:53 -05:00
* @param int $nest
2017-08-21 22:10:48 -05:00
* @param array $data
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
2017-10-06 23:57:53 -05:00
public function handle(int $nest, array $data)
{
if (! is_null(array_get($data, 'author'))) {
unset($data['author']);
}
2018-01-05 16:33:50 -06:00
$this->repository->withoutFreshModel()->update($nest, $data);
}
}