PHPackages                             abather/spatie-laravel-model-states-actions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. abather/spatie-laravel-model-states-actions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

abather/spatie-laravel-model-states-actions
===========================================

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

2.0.1(1mo ago)34561MITPHPPHP ^8.1CI failing

Since Dec 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Abather/spatie-laravel-model-states-actions)[ Packagist](https://packagist.org/packages/abather/spatie-laravel-model-states-actions)[ Docs](https://github.com/abather/spatie-laravel-model-states-actions)[ GitHub Sponsors](https://github.com/Abather)[ RSS](/packages/abather-spatie-laravel-model-states-actions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (13)Used By (0)

spatie-laravel-model-states-actions
===================================

[](#spatie-laravel-model-states-actions)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b5006cd1ad40486623b35bdc4047c59113d3f3a0be4eb8f80188146200137aeb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616261746865722f7370617469652d6c61726176656c2d6d6f64656c2d7374617465732d616374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/abather/spatie-laravel-model-states-actions)[![Total Downloads](https://camo.githubusercontent.com/3399c52e32d33a1fdbdf6bbc7ee558129c1610d6530caf269c69810a4898a8b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616261746865722f7370617469652d6c61726176656c2d6d6f64656c2d7374617465732d616374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/abather/spatie-laravel-model-states-actions)

with this package you can display or add actions to your views using state, this package depends on `spatie/laravel-model-states` package.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require abather/spatie-laravel-model-states-actions
```

Usage
-----

[](#usage)

Follow the Doc in [ Laravel-model-states ](https://spatie.be/docs/laravel-model-states/v2/01-introduction), but for each State you have to extends `Abather\SpatieLaravelModelStatesActions\State` :

```
use Abather\SpatieLaravelModelStatesActions\State;
use Spatie\ModelStates\StateConfig;

abstract class PaymentState extends State
{
    public static function config(): StateConfig
    {
        return parent::config()
            ->default(Pending::class)
            ->allowTransition(Pending::class, Paid::class)
            ->allowTransition(Pending::class, Failed::class)
        ;
    }
}
```

### configure authorization

[](#configure-authorization)

you can define ability name for each state that well be used to determine if the user can change the state or not as:

```
