Download the PHP package abather/spatie-laravel-model-states-actions without Composer
On this page you can find all versions of the php package abather/spatie-laravel-model-states-actions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abather/spatie-laravel-model-states-actions
More information about abather/spatie-laravel-model-states-actions
Files in abather/spatie-laravel-model-states-actions
Package spatie-laravel-model-states-actions
Short Description This is my package spatie-laravel-model-states-actions
License MIT
Homepage https://github.com/abather/spatie-laravel-model-states-actions
Informations about the package spatie-laravel-model-states-actions
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
You can install the package via composer:
Usage
Follow the Doc in Laravel-model-states ,
but for each State you have to extends Abather\SpatieLaravelModelStatesActions\State
:
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:
that mean it well look to ability name called cancel
in OrderPolicy class.
also you can skip authorization by override the attribute $skip_authorization = true
keep in mind that the package also chick if you can transfer to the state using canTransitionTo(Cancel::class)
that come with Spatie Package you can view it here
Customize Action Icon & Color
you can custom the state color and icon by overriding the attributes $color
& $icon
for these attributes you have to follow Filament Doc about each one of them Icon Doc, Color Doc
Localization
you need to create states.php
file to translate the state and the structure of each state should be as:
Display Current State
if you went to display the current state in Edit or Info List you can do so by adding state->display()
method to header actions:
feel free to add it to any place that accept Filament\Actions\Action
object.
View actions in Table:
you can view the available actions 'depends on authorizations as states configuration':
tableActions()
method well return an array of Filament\Tables\Actions\Action
objects.
View actions in any page
you can view the available actions 'depends on authorizations as states configuration' in any resource page:
actions()
will return an array of Filament\Actions\Action
objects, that mean you can use it any place that accept Action
object.
Config ordering actions
if you went to display available actions in specific order you can do so by overriding $order
attribute in each State.
action without confirmation modal
if you don't went the conformation modal you can set attribute $requires_confirmation
to false
in the state:
or change it in the base state class:
this will stop confirmation modal to all states under this class.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Mohammed Aljuraysh
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of spatie-laravel-model-states-actions with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0
spatie/laravel-model-states Version ^2.0