PHP code example of soap / laravel-workflow-process

1. Go to this page and download the library: Download soap/laravel-workflow-process 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/ */

    

soap / laravel-workflow-process example snippets


return [
    'custom_functions' => [
        // 'function_name' => [
        //     'compiler'  => function () { return 'true'; },
        //     'evaluator' => function (array $variables) { return true; },
        // ],
        // 'function_name' => 'App\CustomGuardFunction',
        // 'authenicated' => \Soap\LaravelWorkflowProcess\GuardFunctions\Authenticated::class,

        'authenticated' => [
            'compiler' => function ($guard = 'web') {
                return sprintf('authenticated("%s")', $guard);
            },
            'evaluator' => function (array $variables, $guard = 'web') {
                // This allows checking a specific guard (e.g., 'web', 'api', etc.)
                return auth()->guard($guard)->check();
            },
        ],
    ],
];

// file config/workflow.php
use ZeroDaHero\LaravelWorkflow\MarkingStores\EloquentMarkingStore;

return [
    'blogPost' => [
        'type' => 'workflow',
        'supports' => [App\Models\BlogPost::class],
        'marking_store' => [
            'property' => 'state',
            'type' => 'single_state',
            'class' => EloquentMarkingStore::class,
        ],
        'places' => ['draft', 'pending_for_review', 'approved', 'rejected', 'published', 'archived'],
        'transitions' => [
            'submit' => [
                'from' => 'draft',
                'to' => 'pending_for_review',
                'metadata' => [
                    'guard' => 'authenticated and subject.isOwnedBy(user)',
                ],
            ],
            'approve' => [
                'from' => 'pending_for_review',
                'to' => 'approved',
            ],
            'reject' => [
                'from' => 'pending_for_review',
                'to' => 'rejected',
            ],
            'publish' => [
                'from' => 'approved',
                'to' => 'published',
            ],
            'archive' => [
                'from' => ['draft', 'rejected'],
                'to' => 'archived',
            ],
        ],
    ]
    
];
bash
php artisan vendor:publish --tag="workflow-process-config"