Skip to content

Commit abd2964

Browse files
committed
Update account link delete position reordering
1 parent c6d0719 commit abd2964

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

app/Http/Controllers/Api/AccountController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,19 @@ public function removeProfileLink(Request $request, $id)
787787
{
788788
$profile = $request->user()->profile;
789789
$link = ProfileLink::whereProfileId($profile->id)->findOrFail($id);
790+
790791
$link->delete();
792+
793+
$remainingLinks = ProfileLink::whereProfileId($profile->id)
794+
->orderBy('position')
795+
->orderBy('id')
796+
->get();
797+
798+
foreach ($remainingLinks as $index => $remainingLink) {
799+
$remainingLink->position = $index;
800+
$remainingLink->save();
801+
}
802+
791803
$profile->syncLinksJson();
792804

793805
return $this->data([

0 commit comments

Comments
 (0)