PHP code example of chrisjohnleah / velocity-fleet-api-laravel

1. Go to this page and download the library: Download chrisjohnleah/velocity-fleet-api-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/ */

    

chrisjohnleah / velocity-fleet-api-laravel example snippets


use ChrisJohnLeah\VelocityFleet\Laravel\Facades\VelocityFleet;

foreach (VelocityFleet::customers()->list() as $customer) {
    // Use $customer->id (the unique id) for device positions — not $customer->number.
    $positions = VelocityFleet::devicePositions()->forCustomer($customer->id);

    foreach ($positions->devices as $device) {
        info("{$device->vehicleRegistration} @ {$device->lat},{$device->lon} — ignition ".
            ($device->ignitionOn() ? 'on' : 'off'));
    }
}

use ChrisJohnLeah\VelocityFleet\VelocityFleet;

public function index(VelocityFleet $velocity)
{
    return $velocity->customers()->list();
}

use ChrisJohnLeah\VelocityFleet\Laravel\Facades\VelocityFleet;

$nearby = VelocityFleet::fleet($customer->id)
    ->moving()
    ->inDriverGroup(7)
    ->near($lat, $lon, 5.0);   // within 5 km

use ChrisJohnLeah\VelocityFleet\Laravel\Testing\InteractsWithVelocityFleet;
use ChrisJohnLeah\VelocityFleet\Laravel\Testing\FakeDevice;
// fakeFleet([...]) / FakeDevice::make([...]) / FakeDevicePositions::withDevices([...]) / FleetScenario
bash
php artisan vendor:publish --tag=velocity-fleet-config
php artisan migrate