Weave Code
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

Action Laravel Package

laraditz/action

Define single-purpose Action classes for Laravel and Lumen to keep code DRY. Generate actions via artisan, pass data through constructor properties, and execute with handle() or a convenient static run() method. Includes a data() helper for all properties.

View on GitHub
Deep Wiki
Context7

Laravel Action

Latest Stable Version Total Downloads License StyleCI

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.

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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui