定制 laraditz/action 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

laraditz/action

最新稳定版本:2.0.0

Composer 安装命令:

composer require laraditz/action

包简介

A simple single action class for Laravel to keep your application DRY

README 文档

README

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.

统计信息

  • 总下载量: 1.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-18