PHP code example of renoki-co / laravel-chained-jobs-shared-data

1. Go to this page and download the library: Download renoki-co/laravel-chained-jobs-shared-data 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/ */

    

renoki-co / laravel-chained-jobs-shared-data example snippets


CreateUser::withChain([
    new CreateApiKey,
    new MakeTestApiCall,
])->dispatch();

// CreateUser.php

public function handle()
{
    $user = $this->createUser();

    $this->sharedData['user'] = $user;
}

// CreateApiKey.php

public function handle()
{
    $apiKey = $this->createApiKeyForUser($this->sharedData['user']);

    $this->sharedData['api_key'] = $apiKey;
}

// MakeTestApiCall.php

public function handle()
{
    $this->makeApiCall(
        $this->sharedData['user'],
        $this->sharedData['api_key'],
    );
}