Skip to content

Commit b639921

Browse files
committed
updatePartial refactored
1 parent 5725744 commit b639921

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Http/Controllers/ApiController.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,16 @@ public function index(Request $request): LengthAwarePaginator
3131

3232
protected function updatePartial(Object $object, Request $request)
3333
{
34-
$data = [];
35-
foreach ($request->all() as $column => $content) {
36-
if (is_array($content)) {
37-
foreach ($content as $key => $value) {
38-
$data[$column.'->'.$key] = $value;
34+
foreach ($request->only('status') as $key => $content) {
35+
if ($object->isTranslatableAttribute($key)) {
36+
foreach ($content as $lang => $value) {
37+
$object->setTranslation($key, $lang, $value);
3938
}
4039
} else {
41-
$data[$column] = $content;
40+
$object->{$key} = $content;
4241
}
4342
}
4443

45-
foreach ($data as $key => $value) {
46-
$object->{$key} = $value;
47-
}
4844
$object->save();
4945
}
5046

0 commit comments

Comments
 (0)