Skip to content

Commit

Permalink
Use model-specified soft delete column name (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-tanner authored Sep 29, 2024
2 parents 75f9fa0 + 9cbeb33 commit 244898f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Observers/DeepSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ private function reflectionIterator(callable $callback): void
private function handleDelete(Collection $parents, Model $childRecord): void
{
$parents->filter(function($parent) {
return $parent->deleted_at === null;
$deletedAtColumn = $parent->getDeletedAtColumn();
return $parent->$deletedAtColumn === null;
});

if (!count($parents)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function up(): void
$table->string('title');
$table->text('body');
$table->timestamps();
$table->softDeletes();
$table->timestamp('archive_date')->nullable();
});
}

Expand Down
2 changes: 2 additions & 0 deletions tests/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Post extends Model
'is_active'
];

const DELETED_AT = 'archive_date';

/**
* DeepSync properties and trigger values
*/
Expand Down

0 comments on commit 244898f

Please sign in to comment.