定制 uocnv/orchid-action 二次开发

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

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

uocnv/orchid-action

最新稳定版本:1.0.3

Composer 安装命令:

composer require uocnv/orchid-action

包简介

Action with permission for Orchid

README 文档

README

Added action buttons with permissions to the list panel for Orchid

Installation

You can install the package via composer:

composer require uocnv/orchid-action

Usage

Create an action

php artisan orchid-action:make CustomAction

By default, all actions are placed in the app/Actions/Orchid directory. The action necessarily consists of two methods and permission. Method button defines name, icon, dialog box, etc. And the handler method directly handles the action.

namespace App\Actions\Orchid;

use Illuminate\Http\Request;
use Orchid\Screen\Actions\Button;
use Orchid\Support\Facades\Toast;
use Uocnv\OrchidAction\Action;

class CustomAction extends Action
{
    protected string $permission = 'action.custom';

    /**
     * The button of the action.
     *
     * @return Button
     */
    public function button(): Button
    {
        return Button::make('Run Custom Action')->icon('bs.fire');
    }

    /**
     * Perform the action on the given models.
     *
     * @param Request $request
     */
    public function handle(Request $request)
    {
        Toast::message('It worked!');
    }
}

Within the handle method, you may perform whatever tasks are necessary to complete the action.

And then in Layout, add Action to use

...
TD::make('Action')
    ->alignCenter()
    ->render(function (User $user) {
        return ActiveUser::init([
            'userId' => $user->use_id,
            'type'   => ActiveStatus::INACTIVE
        ])?->cansee(!is_null($user->deleted_at));
    })
...

In Screen must use Actionable trait

namespace App\Http\Controllers\Screens;

use Illuminate\Http\Request;
use Orchid\Screen\Screen;
use Uocnv\OrchidAction\Traits\Actionable;

class Idea extends Screen
{
    use Actionable;
    
    /**
     * Fetch data to be displayed on the screen.
     *
     * @return array
     */
    public function query() : array
    {
        return [];
    }

    /**
     * The name of the screen is displayed in the header.
     *
     * @return string|null
     */
    public function name(): ?string
    {
        return "Idea Screen";
    }

    /**
     * The screen's layout elements.
     *
     * @return \Orchid\Screen\Layout[]|string[]
     */
    public function layout() : array
    {
        return [];
    }
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email uocnv.soict.hust@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-09