PHP code example of igorsgm / laravel-redash

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

    

igorsgm / laravel-redash example snippets


// Returns a paginated array of query objects.
Redash::queries()->all();

// Returns an individual query object.
Redash::queries()->get($queryId);

// Create a new query object.
Redash::queries()->create([
    'name' => 'My Query',
    'data_source_id' => 1,
    'query' => 'SELECT * FROM table',
    'description' => 'My Query Description',
    // ...
]);

// Edit an existing query object.
Redash::queries()->update($queryId, [
    'name' => 'My New Query Name',
    // ...
]);

// Archive an existing query.
Redash::queries()->delete($queryId);

// Get a cached result for this query ID
Redash::queries()->getCachedResult($queryId);

// Initiates a new query execution or returns a cached result.
Redash::queries()->executeOrGetResult($queryId, [
    'parameters' => [
        'foo' => 'bar',
    ],
    'max_age' => 0,
]);

// The maximum age (in milliseconds) of a cached result that the method should return.
// If a cached result is older than this, a new query execution will begin.
// Set to `0` to always start a new execution.
$maxAge = 1800;

// The number of times to retry the query execution if it is still in progress.
$retryAttempts = 20;

Redash::queries()->getResult($queryId, [
    'foo' => 'bar',
], $maxAge, $retryAttempts);

// Returns a query result
Redash::queryResults()->get($queryResultId);

Redash::dashboards()->all();
Redash::dashboards()->get($dashboardId);
Redash::dashboards()->create([
    // ...
]);
Redash::dashboards()->update($dashboardId, [
    // ...
]);
Redash::dashboards()->delete($dashboardId);

Redash::jobs()->get($jobId);
bash
php artisan vendor:publish --tag="laravel-redash-config"