misc_pterodactyl-panel/app/Services/Locations/LocationUpdateService.php
2017-09-25 21:43:01 -05:00

48 lines
1.3 KiB
PHP

<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Locations;
use Pterodactyl\Models\Location;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
class LocationUpdateService
{
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
protected $repository;
/**
* LocationUpdateService constructor.
*
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
*/
public function __construct(LocationRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
* Update an existing location.
*
* @param int|\Pterodactyl\Models\Location $location
* @param array $data
* @return \Pterodactyl\Models\Location
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function handle($location, array $data)
{
$location = ($location instanceof Location) ? $location->id : $location;
return $this->repository->update($location, $data);
}
}