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
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.
Comments