Skip to content

Comments

fix subject() throwing exception for non-SoftDeletes models#1442

Merged
freekmurze merged 1 commit intomainfrom
fix/subject-soft-deletes
Jan 31, 2026
Merged

fix subject() throwing exception for non-SoftDeletes models#1442
freekmurze merged 1 commit intomainfrom
fix/subject-soft-deletes

Conversation

@freekmurze
Copy link
Member

Summary

  • Fixed issue where subject() throws an exception when subject_returns_soft_deleted_models config is true but the subject model doesn't use SoftDeletes trait
  • Changed from withTrashed() to withoutGlobalScope(SoftDeletingScope::class) which safely removes the soft delete scope only if it exists
  • Added test to verify subject can be fetched for models without SoftDeletes

Fixes #456

🤖 Generated with Claude Code

When `subject_returns_soft_deleted_models` config is true, the subject()
method was calling withTrashed() which throws an exception for models
that don't use the SoftDeletes trait.

Changed to use withoutGlobalScope(SoftDeletingScope::class) which safely
removes the soft delete scope only if it exists.

Fixes #456

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@freekmurze freekmurze merged commit abdbe79 into main Jan 31, 2026
31 checks passed
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

Successfully merging this pull request may close these issues.

Subject should only return soft deleted models if that model uses SoftDeletes

1 participant