From 49be4f33d200714ec389e5ff23624f9a7833cf1f Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 30 Sep 2023 10:33:03 -0400 Subject: [PATCH 1/5] add other pivot-based relations to `detach` flag --- database/relations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/relations.md b/database/relations.md index c07281c6..6e1890dd 100644 --- a/database/relations.md +++ b/database/relations.md @@ -52,7 +52,7 @@ Argument | Description `scope` | filters the relation using a supplied scope method. `push` | if set to false, this relation will not be saved via `push`, default: true. `delete` | if set to true, the related model will be deleted if the primary model is deleted or relationship is destroyed, default: false. -`detach` | if set to false the related model will not be automatically detached if the primary model is deleted or the relationship is destroyed. Used by `belongsToMany` relationships only, default: true. +`detach` | if set to false the related model will not be automatically detached if the primary model is deleted or the relationship is destroyed. Used by `belongsToMany`, `morphToMany` and `morphedByMany` relationships only, default: true. `count` | if set to true, the result contains a `count` column only, used for counting relations, default: false. Example filter using **order** and **conditions**: From 3dbac73193d1cdd9777ff766eed88549ba8c7b3d Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 30 Sep 2023 10:34:05 -0400 Subject: [PATCH 2/5] add note about deletedAtColumn for soft deleting pivot-based relations --- database/traits.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/traits.md b/database/traits.md index e5083f23..d4f4b378 100644 --- a/database/traits.md +++ b/database/traits.md @@ -622,6 +622,8 @@ class User extends Model } ``` +> **NOTE:** If the soft deleting relation is using a pivot table, you can set the `deletedAtColumn` flag on the relation definition to change the column that will hold the soft deletion date in the pivot table, otherwise, it defaults to `deleted_at`. + > **NOTE:** If the related model does not use the soft delete trait, it will be treated the same as the `delete` option and deleted permanently. Under these same conditions, when the primary model is restored, all the related models that use the `softDelete` option will also be restored. From 62978e63188f816beaaab1ee52c009bf18ad7e0f Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 30 Sep 2023 10:41:45 -0400 Subject: [PATCH 3/5] remove empty line --- database/traits.md | 1 - 1 file changed, 1 deletion(-) diff --git a/database/traits.md b/database/traits.md index d4f4b378..bf6d5535 100644 --- a/database/traits.md +++ b/database/traits.md @@ -623,7 +623,6 @@ class User extends Model ``` > **NOTE:** If the soft deleting relation is using a pivot table, you can set the `deletedAtColumn` flag on the relation definition to change the column that will hold the soft deletion date in the pivot table, otherwise, it defaults to `deleted_at`. - > **NOTE:** If the related model does not use the soft delete trait, it will be treated the same as the `delete` option and deleted permanently. Under these same conditions, when the primary model is restored, all the related models that use the `softDelete` option will also be restored. From 3f461c52438f8a050d9aebc908e0af4a0b4dd50c Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Tue, 10 Oct 2023 08:46:29 -0600 Subject: [PATCH 4/5] Update database/traits.md --- database/traits.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database/traits.md b/database/traits.md index bf6d5535..871fa9d7 100644 --- a/database/traits.md +++ b/database/traits.md @@ -622,7 +622,8 @@ class User extends Model } ``` -> **NOTE:** If the soft deleting relation is using a pivot table, you can set the `deletedAtColumn` flag on the relation definition to change the column that will hold the soft deletion date in the pivot table, otherwise, it defaults to `deleted_at`. +> **NOTE:** If the soft deleting relation is using a pivot table, you can set the `deletedAtColumn` option on the relation definition to change the column that will hold the soft deletion date in the pivot table, otherwise, it defaults to `deleted_at`. + > **NOTE:** If the related model does not use the soft delete trait, it will be treated the same as the `delete` option and deleted permanently. Under these same conditions, when the primary model is restored, all the related models that use the `softDelete` option will also be restored. From 929a09e73fcf814c671593778168cb264a9c2cfb Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Tue, 10 Oct 2023 08:48:46 -0600 Subject: [PATCH 5/5] Remove empty line again @bennothommo why are these separation lines linted out? --- database/traits.md | 1 - 1 file changed, 1 deletion(-) diff --git a/database/traits.md b/database/traits.md index 871fa9d7..32f8fb70 100644 --- a/database/traits.md +++ b/database/traits.md @@ -623,7 +623,6 @@ class User extends Model ``` > **NOTE:** If the soft deleting relation is using a pivot table, you can set the `deletedAtColumn` option on the relation definition to change the column that will hold the soft deletion date in the pivot table, otherwise, it defaults to `deleted_at`. - > **NOTE:** If the related model does not use the soft delete trait, it will be treated the same as the `delete` option and deleted permanently. Under these same conditions, when the primary model is restored, all the related models that use the `softDelete` option will also be restored.