pelican-panel-banquise/app/Services/Locations/LocationUpdateService.php
2024-03-12 22:39:16 -04:00

30 lines
726 B
PHP

<?php
namespace App\Services\Locations;
use App\Models\Location;
use App\Contracts\Repository\LocationRepositoryInterface;
class LocationUpdateService
{
/**
* LocationUpdateService constructor.
*/
public function __construct(protected LocationRepositoryInterface $repository)
{
}
/**
* Update an existing location.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws \App\Exceptions\Repository\RecordNotFoundException
*/
public function handle(Location|int $location, array $data): Location
{
$location = ($location instanceof Location) ? $location->id : $location;
return $this->repository->update($location, $data);
}
}