PHP code example of masmerise / scrada-for-laravel

1. Go to this page and download the library: Download masmerise/scrada-for-laravel 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/ */

    

masmerise / scrada-for-laravel example snippets


'scrada' => [
    'default' => env('SCRADA_COMPANY', 'default'),
    
    'companies' => [
        'default' => [
            'api_key' => env('SCRADA_API_KEY'),
            'password' => env('SCRADA_PASSWORD'),
            'env' => env('SCRADA_ENV', 'production'), // or 'test'
        ],
    ],
],

// Resolve a Scrada instance for a specific company
$company = scrada('default')->company->get($id);

// Resolve the manager and use the default company
$scrada = app('scrada');

$company = $scrada->company('default')->company->get($id);

use Scrada\Company\Type\Primitive\CompanyId;
use Scrada\Laravel\ScradaManager;

final readonly class CompanyController
{
    private function __construct(private ScradaManager $scrada) {}
    
    public function show(string $company, string $id): void
    {
        $id = CompanyId::fromString($id);
    
        return view('company.show', [
            'company' => $this->scrada->company($company)->company->get($id),
        ]);
    }
}