PHP code example of uocnv / orchid-action

1. Go to this page and download the library: Download uocnv/orchid-action library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

uocnv / orchid-action example snippets


php artisan orchid-action:make CustomAction

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!');
    }
}

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

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 [];
    }
}