Skip to content

Commit

Permalink
Update empty fields
Browse files Browse the repository at this point in the history
  • Loading branch information
andyksaw committed Nov 28, 2024
1 parent ef38157 commit a24412e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/Http/Controllers/Api/v2/Minecraft/MinecraftBuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@ public function patch(Request $request, MinecraftBuild $build)

$this->assertHasWriteAccess(build: $build, uuid: $input['player_uuid']);

$build->name = $request->get('name', default: $build->name);
$build->description = $request->get('description', default: $build->description);
$build->lore = $request->get('lore', default: $build->lore);
if ($request->has('name')) {
$name = $request->get('name');
$build->name = empty($name) ? null : $name;
}
if ($request->has('description')) {
$description = $request->get('description');
$build->description = empty($description) ? null : $description;
}
if ($request->has('lore')) {
$lore = $request->get('lore');
$build->lore = empty($lore) ? null : $lore;
}
$build->save();

return $build;
Expand Down

0 comments on commit a24412e

Please sign in to comment.