Fix tests
This commit is contained in:
parent
126c9e940f
commit
c2c3465dc4
2 changed files with 9 additions and 6 deletions
|
@ -24,11 +24,9 @@ class LocationDeletionService
|
||||||
*/
|
*/
|
||||||
public function handle(Location|int $location): ?int
|
public function handle(Location|int $location): ?int
|
||||||
{
|
{
|
||||||
$location = ($location instanceof Location) ? $location->id : $location;
|
$location = ($location instanceof Location) ? $location : $location->id;
|
||||||
|
|
||||||
Assert::integerish($location, 'First argument passed to handle must be numeric or an instance of ' . Location::class . ', received %s.');
|
$count = $location->nodes()->count();
|
||||||
|
|
||||||
$count = $this->nodeRepository->findCountWhere([['location_id', '=', $location]]);
|
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
throw new HasActiveNodesException(trans('exceptions.locations.has_nodes'));
|
throw new HasActiveNodesException(trans('exceptions.locations.has_nodes'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,13 @@ class LocationUpdateService
|
||||||
*/
|
*/
|
||||||
public function handle(Location|int $location, array $data): Location
|
public function handle(Location|int $location, array $data): Location
|
||||||
{
|
{
|
||||||
$location = ($location instanceof Location) ? $location->id : $location;
|
/** @var Location $location */
|
||||||
|
if (is_int($location)) {
|
||||||
|
$location = Location::query()->findOrFail($location);
|
||||||
|
}
|
||||||
|
|
||||||
return $location->update($data);
|
$location->update($data);
|
||||||
|
|
||||||
|
return $location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue