Skip to content

Commit 864c21e

Browse files
committed
updatePartial refactored
1 parent 3642596 commit 864c21e

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
@@ -39,20 +39,16 @@ function ($item) {
3939

4040
protected function updatePartial(Slide $slide, Request $request)
4141
{
42-
$data = [];
43-
foreach ($request->all() as $column => $content) {
44-
if (is_array($content)) {
45-
foreach ($content as $key => $value) {
46-
$data[$column.'->'.$key] = $value;
42+
foreach ($request->only('status', 'position') as $key => $content) {
43+
if ($slide->isTranslatableAttribute($key)) {
44+
foreach ($content as $lang => $value) {
45+
$slide->setTranslation($key, $lang, $value);
4746
}
4847
} else {
49-
$data[$column] = $content;
48+
$slide->{$key} = $content;
5049
}
5150
}
5251

53-
foreach ($data as $key => $value) {
54-
$slide->{$key} = $value;
55-
}
5652
$slide->save();
5753
}
5854

0 commit comments

Comments
 (0)