Skip to content

Fix ArgumentCountError when the audited model is missing - #72

Merged
andreia merged 2 commits into
4.xfrom
fix_gate_params
Aug 21, 2026
Merged

Fix ArgumentCountError when the audited model is missing#72
andreia merged 2 commits into
4.xfrom
fix_gate_params

Conversation

@andreia

@andreia andreia commented Aug 20, 2026

Copy link
Copy Markdown
Member

Details

The default audit and restoreAudit gates required a second argument. Laravel Auditing’s auditable relation is morphTo() without withTrashed(), so $record->auditable is null when the related model has been deleted or soft-deleted. Filament then called can('restoreAudit', null) while rendering the audits table, which invoked the gate with only the user and threw:

Too few arguments to function … FilamentAuditingServiceProvider::packageBooted() … 1 passed … exactly 2 expected

This matches TappNetwork/filament-auditing#67.

This PR make the resource argument optional on both gates so a missing auditable does not crash. Hide the restore action unless the auditable still exists and the event is updated. This follows Laravel Auditing: $audit->auditable may be null by default; apps that need soft-deleted models can opt into a custom Audit model with withTrashed() via config/audit.php implementation. Hard-deleted models remain null either way, and restore still requires a live record.

@andreia
andreia requested a review from swilla August 20, 2026 23:47
@andreia
andreia merged commit 29e03bc into 4.x Aug 21, 2026
1 check 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.

2 participants