PHP code example of spits-online / laravel-openprovider-api

1. Go to this page and download the library: Download spits-online/laravel-openprovider-api 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/ */

    

spits-online / laravel-openprovider-api example snippets


use Spits\LaravelOpenproviderApi\Services\DomainService;

$domains = app(new DomainService())->index(options: ['limit' => 100, 'offset' => 100]);

use Spits\LaravelOpenproviderApi\Services\DomainService;

$domain = app(new DomainService())->getDomain(id: 'Openprovider ID');

use Spits\LaravelOpenproviderApi\Services\DomainService;

$response = new DomainService()->updateDomain(id: 'id', data: []);



use Spits\LaravelOpenproviderApi\Services\DnsService;

class DnsRecordsController {
    public function show(string $domain, DnsService $service) 
    {
        $options = request()->get('options', ['with_records' => 'true']);

        $response = $service->getDnsZone($domain, $options);

        return $response->collect();
    }
}

use Spits\LaravelOpenproviderApi\Services\DnsService;

class DnsRecordsController {
    public function store(string $domain, DnsService $service, DnsRecordStoreRequest $request)
    {
        $data = [
            'provider' => $request->validated('provider'),
            'records' => [
                'add' => [
                    $request->validated('record'),
                ],
            ],
        ];

        return $service->updateDnsZone($domain, $data);
    }
}

use Spits\LaravelOpenproviderApi\Services\DnsService;

class DnsRecordsController {
    public function export(string $domain, DnsService $service)
    {
        $options = request()->get('options', ['with_records' => 'true']);

        $response = $service->getDnsZone($domain, $options);
        $data = $response->collect();
        $collection = collect($data['data']['records'])->map(function ($item) {
            return (object) $item;
        });

        $export = new DnsZoneExport($collection);

        return Excel::download($export, 'dns_zone_'.$domain.'.xlsx');
    }
}
bash
   php artisan vendor:publish --tag="laravel-openprovider-api-config"