Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Spatie Laravel Model States Actions

Spatie Laravel Model States Actions Laravel Package

abather/spatie-laravel-model-states-actions

Add state-based actions to Laravel views with this extension for spatie/laravel-model-states. Define per-state authorization abilities, skip checks when needed, and customize action icons and colors. Includes transition checks via canTransitionTo.

View on GitHub
Deep Wiki
Context7

This is my package spatie-laravel-model-states-actions

Frequently asked questions about Spatie Laravel Model States Actions
What is abather/spatie-laravel-model-states-actions?
It is a Composer package that adds Filament actions for models using spatie/laravel-model-states. It lets you display or add actions in your views based on the current model state. The package depends on Spatie's Laravel Model States package and extends its state classes with Filament-specific behavior.
How do I install abather/spatie-laravel-model-states-actions?
Install it with Composer using composer require abather/spatie-laravel-model-states-actions. Then follow the spatie/laravel-model-states documentation for defining your states. Each state class should extend Abather\SpatieLaravelModelStatesActions\State instead of the base Spatie state class.
Which Laravel and Filament versions are supported?
The README excerpt does not list explicit Laravel or Filament version constraints. You should check the package's composer.json on Packagist or GitHub for the exact requirements. Because it depends on spatie/laravel-model-states, your Laravel version must also satisfy that package's constraints.
How do I define states for this package?
Define your state classes as you would with spatie/laravel-model-states, but extend Abather\SpatieLaravelModelStatesActions\State. In each abstract state class, implement the static config method and return a StateConfig using parent::config() with default and allowTransition calls. The README example shows configuring default, paid, and failed transitions.
How does authorization work for state actions?
You can set a protected static ?string $ability property on a state class, such as 'cancel'. The package uses that ability name to check the related model policy, for example OrderPolicy, to decide whether the user can change to that state. It also checks whether the transition is allowed using canTransitionTo from Spatie's package.
Can I skip authorization for a state action?
Yes. Override the $skip_authorization attribute and set it to true on the state class. This bypasses the policy ability check for that state action. Keep in mind that the package still checks whether the transition is allowed via canTransitionTo.
Does the package check allowed state transitions?
Yes. The package checks whether a model can transition to the target state using canTransitionTo, which comes from spatie/laravel-model-states. This means your StateConfig allowTransition rules still control which actions are valid. Authorization is an additional check on top of the transition rules.
How do I customize the action icon and color?
Override the protected static ?string $color and $icon attributes on your state class. For example, set $color to 'danger' and $icon to a Heroicon name such as 'heroicon-o-cursor-arrow-rays'. The README directs you to Filament's documentation for valid icon and color values.
How can I test state actions in my Laravel application?
The README does not document package-specific testing helpers. You can test state actions using normal Laravel and Filament testing approaches, including policy checks and Spatie state transition assertions. Verify that canTransitionTo returns the expected result and that the policy ability allows or denies the action.
Is this package suitable for production, and what are the alternatives?
It is a small wrapper around spatie/laravel-model-states, so production suitability depends on its maintenance status and your version constraints. Check Packagist downloads, GitHub issues, and recent commits before adopting it. As an alternative, you can build Filament actions manually on top of Spatie's state and transition APIs without this package.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
alphabalex/messaging-made-easy
rawphp/warp
shootkiran/merobug
narakode/fineauth
numencode/wn-syncops-plugin
ibnnajjaar/mib-global-pay
ably/pubsub-server
mstfkhazaal/defender
mfonte/base62x
karnoweb/metapilot
tobya/bcsapiwrapper
swalker2/cpanel
vish4395/laravel-translation-manager
morningtrain/economic
teksite/systeminfo-laravel
atomcms/voting
run6/weather
siokas/laravelembeddirectives
adamlien/pkuuids
gilsonsouza/lara-doc-generator