Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-Attaching does not undelete #14

Open
boryn opened this issue Nov 24, 2021 · 0 comments
Open

Re-Attaching does not undelete #14

boryn opened this issue Nov 24, 2021 · 0 comments

Comments

@boryn
Copy link

boryn commented Nov 24, 2021

Hi!

When I do the "normal" ->detach($post->id) I get as expected the timestamp at the deleted_at column.

But when I'd like to set the reassignment again by using ->attach() like:

$user->managedPosts()->attach(
                [
                    $post->id => [
                        'relationship_type' => $pivotFields['relationship_type'],
                        'role_id'           => $pivotFields['role_id'],
                    ],
                ]
            );

unfortunately the value of deleted_at is not changed to NULL and actually the assignment is still deleted.

I saw in the documentation about $post->tags()->restore([$tag->id]); and I tried:

$user->managedPosts()->restore(
                [
                    $post->id => [
                        'relationship_type' => $pivotFields['relationship_type'],
                        'role_id'           => $pivotFields['role_id'],
                    ],
                ]
            );

but with no success.

IMHO using the standard Laravel method ->attach() should reactivate the assignment by removing the timestamp from deleted_at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant