PHP code example of arabiacode / laravel-flow-builder

1. Go to this page and download the library: Download arabiacode/laravel-flow-builder 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/ */

    

arabiacode / laravel-flow-builder example snippets


use Arabiacode\LaravelFlowBuilder\Models\Flow;

$flow = Flow::create([
    'name' => 'Order Processing',
    'description' => 'Process new orders automatically',
    'is_active' => true,
]);

use Arabiacode\LaravelFlowBuilder\Models\FlowTrigger;

FlowTrigger::create([
    'flow_id' => $flow->id,
    'type' => 'model',
    'model_class' => \App\Models\Order::class,
    'event' => 'created',
]);

$schedule->command('flow-builder:run-scheduled')->everyMinute();

use Arabiacode\LaravelFlowBuilder\Contracts\NodeExecutor;
use Arabiacode\LaravelFlowBuilder\Engine\FlowState;
use Arabiacode\LaravelFlowBuilder\Models\FlowNode;

class SmsExecutor implements NodeExecutor
{
    public function execute(FlowNode $node, FlowState $state): mixed
    {
        return ['ok' => true];
    }
}

'executors' => [
    'sms' => \App\FlowExecutors\SmsExecutor::class,
],

use Arabiacode\LaravelFlowBuilder\Facades\FlowBuilder;
use Arabiacode\LaravelFlowBuilder\Models\Flow;

$flow = Flow::findOrFail(1);

$execution = FlowBuilder::execute($flow, [
    'order_id' => 1201,
    'customer_name' => 'Sara',
]);

$status = $execution->status;
bash
php artisan migrate
bash
php artisan vendor:publish --tag=flow-builder-config
bash
php artisan vendor:publish --tag=flow-builder-views
bash
php artisan flow-builder:run-scheduled
php artisan flow-builder:clear-cache
bash
php artisan queue:work --queue=flows