2017-06-15 04:53:24 +00:00
|
|
|
<?php
|
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
namespace Pterodactyl\Services\Locations;
|
2017-06-15 04:53:24 +00:00
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
use Pterodactyl\Models\Location;
|
2017-07-03 02:29:58 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
2017-06-15 04:53:24 +00:00
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
class LocationUpdateService
|
2017-06-15 04:53:24 +00:00
|
|
|
{
|
|
|
|
/**
|
2017-09-15 05:16:03 +00:00
|
|
|
* LocationUpdateService constructor.
|
2017-06-15 04:53:24 +00:00
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(protected LocationRepositoryInterface $repository)
|
2017-06-15 04:53:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-15 05:16:03 +00:00
|
|
|
* Update an existing location.
|
2017-06-15 04:53:24 +00:00
|
|
|
*
|
2017-06-25 00:49:09 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-09-15 05:16:03 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-06-15 04:53:24 +00:00
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function handle(Location|int $location, array $data): Location
|
2017-06-15 04:53:24 +00:00
|
|
|
{
|
2017-09-15 05:16:03 +00:00
|
|
|
$location = ($location instanceof Location) ? $location->id : $location;
|
2017-06-15 04:53:24 +00:00
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
return $this->repository->update($location, $data);
|
2017-06-15 04:53:24 +00:00
|
|
|
}
|
|
|
|
}
|