Soft deleting a many-to-many relationship's pivot in Eloquent

Kousha

Is there a way to 'soft delete' a many-to-many relationship? I've already added a deleted_at column to my pivot table and am using the SoftDeletingTrait. But when you detach the two relationships, the row is completely deleted.

I have the tables clients, users and client_user. I am hoping that somehow, using User::find($user_id)->detach($client_id) would not actually delete the pivot row, but set the deleted_at to the current timestamp.

And then continuing after this, I don't want to be able to get soft-deleted items back. However, at the moment, even if I manually set the value of deleted_at, I still get the result

Roberto Antezana
DB::table('client_user')
                ->where('client_id', $client->id)
                ->where('user_id', $user->id)
                ->update(array('deleted_at' => DB::raw('NOW()')));

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Soft deleting a many-to-many relationship's pivot in Eloquent

From Dev

Laravel Eloquent Many to Many relationship using a pivot table

From Dev

Laravel Eloquent many-to-many relationship: Use explicit pivot table

From Dev

eloquent: query many to many relationship

From Dev

Laravel eloquent one to many relationship in custom pivot tables

From Dev

Eloquent many to many relationship access table column value from pivot table

From Dev

Deleting correct in a many-to-many relationship

From Dev

Deleting with one-to-many relationship

From Dev

Eloquent - Many to many where not found in the pivot table

From Dev

Creating one to many relationship with pivot table of many to many relationship

From Dev

Creating one to many relationship with pivot table of many to many relationship

From Dev

Laravel Removing Pivot data in many to many relationship

From Dev

Laravels Eloquent to store many to many relationship

From Dev

Laravel many to many relationship using Eloquent

From Dev

Laravel 5 Eloquent count many to many relationship

From Dev

Updating a One-To-Many Relationship in Laravel's Eloquent

From Dev

When deleting an entity with many to many relationship in nhibernate the relationship is not deleted

From Dev

Should eloquent's many-to-many pivot table enforce uniqueness accross the two id columns? Laravel 5

From Dev

Laravel 5 Deleting a one-to-many relationship

From Dev

Deleting an entity record in a many to many relationship with EF6

From Dev

Deleting a many-to-many relationship object in Entity Framework

From Dev

Deleting an entity record in a many to many relationship with EF6

From Dev

Laravel / Eloquent - Many to many pivot model with morphToMany relation

From Dev

Eloquent Many to Many with Pivot table to refactor the returned results to a specific array

From Dev

laravel update, remove one to many relationship eloquent

From Dev

Laravel eloquent update one-many relationship

From Dev

Laravel 5 Eloquent Relationship - Has Many Though

From Dev

Laravel eloquent update one-many relationship

From Dev

Laravel 5 one to many eloquent relationship

Related Related

  1. 1

    Soft deleting a many-to-many relationship's pivot in Eloquent

  2. 2

    Laravel Eloquent Many to Many relationship using a pivot table

  3. 3

    Laravel Eloquent many-to-many relationship: Use explicit pivot table

  4. 4

    eloquent: query many to many relationship

  5. 5

    Laravel eloquent one to many relationship in custom pivot tables

  6. 6

    Eloquent many to many relationship access table column value from pivot table

  7. 7

    Deleting correct in a many-to-many relationship

  8. 8

    Deleting with one-to-many relationship

  9. 9

    Eloquent - Many to many where not found in the pivot table

  10. 10

    Creating one to many relationship with pivot table of many to many relationship

  11. 11

    Creating one to many relationship with pivot table of many to many relationship

  12. 12

    Laravel Removing Pivot data in many to many relationship

  13. 13

    Laravels Eloquent to store many to many relationship

  14. 14

    Laravel many to many relationship using Eloquent

  15. 15

    Laravel 5 Eloquent count many to many relationship

  16. 16

    Updating a One-To-Many Relationship in Laravel's Eloquent

  17. 17

    When deleting an entity with many to many relationship in nhibernate the relationship is not deleted

  18. 18

    Should eloquent's many-to-many pivot table enforce uniqueness accross the two id columns? Laravel 5

  19. 19

    Laravel 5 Deleting a one-to-many relationship

  20. 20

    Deleting an entity record in a many to many relationship with EF6

  21. 21

    Deleting a many-to-many relationship object in Entity Framework

  22. 22

    Deleting an entity record in a many to many relationship with EF6

  23. 23

    Laravel / Eloquent - Many to many pivot model with morphToMany relation

  24. 24

    Eloquent Many to Many with Pivot table to refactor the returned results to a specific array

  25. 25

    laravel update, remove one to many relationship eloquent

  26. 26

    Laravel eloquent update one-many relationship

  27. 27

    Laravel 5 Eloquent Relationship - Has Many Though

  28. 28

    Laravel eloquent update one-many relationship

  29. 29

    Laravel 5 one to many eloquent relationship

HotTag

Archive