Action
Action is Wirechat's audit-style polymorphic action model.
It is used for package-level state changes such as deletions and admin removals.
Core fields:
| Field | Purpose |
|---|---|
actionable_id |
Target model id. |
actionable_type |
Target model morph class. |
actor_id |
Actor model id. |
actor_type |
Actor model morph class. |
type |
Action enum such as delete or removed-by-admin. |
data |
Optional extra payload for the action. |
Important Relationships
actionable(): MorphTo
Returns the model the action was performed on.
$action->actionable
actor(): MorphTo
Returns the model that performed the action. In package flows this is often a Participant.
$action->actor
Important Query Helpers
whereActor(Model $actor)
Filters actions created by a specific actor.
Action::query()->whereActor($participant)->get()
withoutActor(Model $model)
Excludes actions created by a specific actor.
Action::query()->withoutActor($participant)->get()
Common package uses:
- Message delete-for-user actions.
- Participant removed-by-admin actions.
- Other audit-style state changes attached to conversations, messages, or participants.
If you add custom action types in your app, extending this model is a clean place to centralize action formatting or app-specific helpers.