Skip to content

Actions

ActionInterface

Action interface.

php
Lartrix\Schema\Actions\ActionInterface

SetAction

Set state value.

php
use Lartrix\Schema\Actions\SetAction;

SetAction::make('name', 'value')->toArray();

// Output
// ['action' => 'set', 'name' => 'name', 'value' => 'value']

Parameters

ParameterTypeDescription
$namestringVariable name, supports dot notation
$valuemixedValue

CallAction

Call a method.

php
use Lartrix\Schema\Actions\CallAction;

CallAction::make('$message.success', ['param1', 'param2'])->toArray();

Built-in Methods

MethodDescription
$message.successSuccess message
$message.errorError message
$message.warningWarning message
$message.infoInfo message
$dialog.successSuccess dialog
$dialog.errorError dialog
$dialog.warningWarning dialog
$loadingBar.startStart loading bar
$loadingBar.finishFinish loading bar
$loadingBar.errorLoading bar error
$nav.pushNavigate to page
$nav.replaceReplace current page
$nav.backGo back
$tab.closeClose tab
$tab.openOpen tab
$window.openOpen new window
$downloadDownload file

FetchAction

HTTP request action.

php
use Lartrix\Schema\Actions\FetchAction;

FetchAction::make('/api/users')
    ->get()
    ->params(['page' => 1])
    ->then([...])
    ->catch([...]);

HTTP Methods

MethodDescription
get()GET request
post()POST request
put()PUT request
patch()PATCH request
delete()DELETE request

Chaining Methods

MethodDescription
body($data)Request body
params($params)URL parameters
headers($headers)Request headers
then($actions)Success callback
catch($actions)Failure callback
finally($actions)Final callback

IfAction

Conditional action.

php
use Lartrix\Schema\Actions\IfAction;

IfAction::make('{{ condition }}')
    ->true([...])
    ->false([...]);

ScriptAction

Execute a script.

php
use Lartrix\Schema\Actions\ScriptAction;

ScriptAction::make('console.log("debug")');

EmitAction

Emit an event.

php
use Lartrix\Schema\Actions\EmitAction;

EmitAction::make('event-name', ['param']);

CopyAction

Copy to clipboard.

php
use Lartrix\Schema\Actions\CopyAction;

CopyAction::make('text to copy');

WebSocketAction

WebSocket operation.

php
use Lartrix\Schema\Actions\WebSocketAction;

WebSocketAction::make('channel')
    ->action('send')
    ->payload(['data' => 'value']);

基于 MIT 许可发布