laraditz / action
A simple single action class for Laravel to keep your application DRY
Installs: 1 380
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:laravel-package
Requires
- php: ^8.0
- illuminate/console: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
This package is auto-updated.
Last update: 2025-06-09 13:37:30 UTC
README
Single action class for Laravel and Lumen to keep your application DRY.
Installation
Via Composer
$ composer require laraditz/action
Usage
You can use php artisan make:action <name>
to create your action. For example, php artisan make:action CreateNewPost
. By default you can find it in App/Actions
folder.
Sample action file generated with some logic added as below:
namespace App\Actions; use App\Models\Post; use Laraditz\Action\Action; class CreateNewPost extends Action { public function __construct( public string $title, public string $body ) {} public function handle(): void { // You can use $this->data() helper to retreive all properties. Post::create($this->data()); } }
Now that you've created your action, you can call it in few ways as below:
Using plain object
$createNewPost = new CreateNewPost( title: 'My first post', body: 'This is a post content' ); $createNewPost->handle();
Using static method
CreateNewPost::run( title: 'My first post', body: 'This is a post content' );
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email raditzfarhan@gmail.com instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.