PHP code example of quatrebarbes / snow-driver

1. Go to this page and download the library: Download quatrebarbes/snow-driver 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/ */

    

quatrebarbes / snow-driver example snippets


'servicenow' => [
    'driver' => 'servicenow',
    'database' => '',
    'base_url' => env('SNOW_BASE_URL'),
    'timeout' => env('SNOW_TIMEOUT', 30),
    'auth' => [
        'mode' => env('SNOW_AUTH_MODE', 'basic'),
        'username' => env('SNOW_USERNAME'),
        'password' => env('SNOW_PASSWORD'),
    ],
],

use Quatrebarbes\SnowDriver\Eloquent\ServiceNowModel;

class Incident extends ServiceNowModel
{
    protected $connection = 'servicenow';
    protected $table = 'incident';
}

Incident::where('active', true)
    ->orderBy('sys_created_on', 'desc')
    ->limit(20)
    ->get();

use Illuminate\Support\Facades\Schema;

$schema = Schema::connection('servicenow');

$schema->getTableListing();              // noms techniques des tables de l'instance
$schema->hasTable('incident');
$schema->getColumns('incident');         // champs hérités des tables parentes compris
$schema->getColumnListing('incident');
$schema->hasColumn('incident', 'number');
$schema->getForeignKeys('incident');     // déduites des champs de type reference

Incident::count();                       // fonction d'agrégation de l'API, sans rapatriement
Incident::paginate(20);                  // total et nombre de pages inclus
Incident::where('active', true)->exists();

'models' => [
    'tables' => ['incident', 'sys_user', 'task'],
    'namespace' => env('SNOW_MODELS_NAMESPACE', 'App\\Models'),
],
bash
php artisan vendor:publish --tag=servicenow-config