PHP code example of estin92 / laravel-dvla-ves

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

    

estin92 / laravel-dvla-ves example snippets


use Estin92\DvlaVes\Facades\DvlaVes;

$vehicle = DvlaVes::lookup('AB12CDE');

// Identity & build
$vehicle->registrationNumber;            // string            "AB12CDE"
$vehicle->make;                          // ?string           "FORD"
$vehicle->colour;                        // ?string           "BLUE"
$vehicle->yearOfManufacture;             // ?int              2012
$vehicle->wheelplan;                     // ?Wheelplan (enum)
$vehicle->typeApproval;                  // ?TypeApproval (enum)

// Engine & emissions
$vehicle->fuelType;                      // ?FuelType (enum)
$vehicle->engineCapacity;                // ?int              1560   (cc)
$vehicle->co2Emissions;                  // ?int              104    (g/km)
$vehicle->revenueWeight;                 // ?int              null   (kg, goods vehicles)
$vehicle->euroStatus;                    // ?EuroStatus (enum)
$vehicle->realDrivingEmissions;          // ?string           "1"

// Tax
$vehicle->taxStatus;                     // ?TaxStatus (enum)
$vehicle->taxDueDate;                    // ?CarbonImmutable
$vehicle->artEndDate;                    // ?CarbonImmutable   (luxury-car VED supplement end)

// MOT
$vehicle->motStatus;                     // ?MotStatus (enum)
$vehicle->motExpiryDate;                 // ?CarbonImmutable

// Registration history
$vehicle->monthOfFirstRegistration;      // ?string "2012-03"  (or ?CarbonImmutable, see below)
$vehicle->monthOfFirstDvlaRegistration;  // ?string "2012-03"  (or ?CarbonImmutable, see below)
$vehicle->dateOfLastV5CIssued;           // ?CarbonImmutable

// Flags
$vehicle->markedForExport;               // ?bool
$vehicle->automatedVehicle;              // ?bool              (see note below)

// The untouched decoded API payload, if you need a field not surfaced above
$vehicle->rawResponse;                   // array<string, mixed>

$vehicle->isPetrol();                    // fuelType === Petrol
$vehicle->isDiesel();                    // fuelType === Diesel
$vehicle->isElectric();                  // fuelType === Electricity
$vehicle->isHybrid();                    // fuelType === HybridElectric

$vehicle->isTaxed();                     // taxStatus === Taxed
$vehicle->isSorn();                      // taxStatus === Sorn
$vehicle->isTaxDue();                    // taxStatus === Untaxed
$vehicle->hasValidMot();                 // motStatus === Valid

$vehicle->isMarkedForExport();           // markedForExport ?? false
$vehicle->isAutomatedVehicle();          // automatedVehicle ?? false
$vehicle->isSubjectToAdditionalRateOfTax(); // artEndDate is in the future

$vehicle->getFirstRegistrationDate();    // ?CarbonImmutable (start of month), parsed on demand
$vehicle->additionalRateOfTaxEndDate();  // ?CarbonImmutable  alias for artEndDate

$vehicle->fuelType?->label();            // "Petrol"        (translatable via dvla-ves::enums)
$vehicle->taxStatus?->label();           // "Taxed"
$vehicle->motStatus?->isValid();         // bool

if ($vehicle->fuelType?->isElectric()) {
    // ...
}

use Estin92\DvlaVes\Exceptions\DvlaVesException;
use Estin92\DvlaVes\Exceptions\VehicleNotFoundException;
use Estin92\DvlaVes\Exceptions\RateLimitExceededException;

try {
    $vehicle = DvlaVes::lookup('AB12CDE');
} catch (VehicleNotFoundException $e) {
    // 404 - no vehicle for that registration
} catch (RateLimitExceededException $e) {
    $e->retryAfter;                      // ?int seconds, from the Retry-After header
} catch (DvlaVesException $e) {
    // any other DVLA VES failure (invalid registration, service unavailable, ...)
    report($e);
}

use Estin92\DvlaVes\Support\KnownMake;

KnownMake::isKnown('ford');          // true  (case-insensitive, trimmed)
KnownMake::canonical('  land rover');// "LAND ROVER" (DVLA's own spelling)
KnownMake::all();                    // list<string> of every known make

DvlaVes::fake([
    'AB12CDE' => ['registrationNumber' => 'AB12CDE', 'make' => 'FORD'],
]);

DvlaVes::lookup('AB12CDE')->make; // "FORD"
bash
php artisan vendor:publish --tag=dvla-ves-config
bash
php artisan dvla-ves:lookup AB12CDE
bash
php artisan boost:update --discover