misc_pterodactyl-panel/app/Services/Locations/LocationUpdateService.php

49 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2017-09-26 02:43:01 +00:00
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
2017-09-26 02:43:01 +00:00
* 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
2019-09-06 04:32:57 +00:00
* @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);
}
}