Custom Methods - joshuapack/laravel-cloudflare GitHub Wiki

What we got here are some custom methods, that allow you to do some things that pass back as a Laravel Collection. Click on the Cloudflare API to see Example Responses.

Custom Methods

listZones

  • string $name = ''
  • string $status = ''
  • int $page = 1
  • int $perPage = 20
  • string $order = ''
  • string $direction = ''
  • string $match = 'all'

This is a direct call to Cloudflares API List Zones

Example:

    protected $cloudflare = null;
    protected $allZones = null;

    public function __construct()
    {
        $this->cloudflare = app()->make('laravel-cloudflare');
        parent::__construct();
    }
    public function handle()
    {
        $this->grabAllZones();
    }
    private function grabAllZones()
    {
        $this->allZones = $this->cloudflare->listZones('', '', 1, 100)->result;
        return $this;
    }

addRecord

  • string $name
  • $content = null
  • string $type = 'A'
  • int $ttl = 0
  • bool $proxied = true

This is a direct call to Cloudflares API Create DNS Record

Example:

    public function handle()
    {
        $this->cloudflare->addRecord('hightekdesigns.com', '127.0.0.1', 'A', 1, true);
    }

listRecords

  • bool $info = false
  • int $page = 1
  • int $perPage = 20
  • string $order = ''
  • string $direction = ''
  • string $type = ''
  • string $name = ''
  • string $content = ''
  • string $match = 'all'

This is a direct call to Cloudflares API List DNS Records

Example:

    public function handle()
    {
        // This will call back the full record
        $this->cloudflare->listRecords();
        // This will call back the results as a Laravel Collection
        $this->cloudflare->listRecords(true);
    }

getRecordDetails

  • string $recordId

This is a direct call to Cloudflares API DNS Record Details

Example:

    public function handle()
    {
        $this->cloudflare->getRecordDetails('235b53n5b4314523523');
    }

updateRecordDetails

  • string $recordId
  • array $details

This is a direct call to Cloudflares API Update DNS Record

Example:

    public function handle()
    {
        $this->cloudflare->updateRecordDetails('235b53n5b4314523523', [
            "type":"A","name":"hightekdesigns.com","content":"127.0.0.1","ttl":1,"proxied":true
        ]);
    }

deleteRecord

  • string $recordId

This is a direct call to Cloudflares API Delete DNS Record

Example:

    public function handle()
    {
        $this->cloudflare->deleteRecord('235b53n5b4314523523');
    }

listIPs

  • string $recordId

This is a direct call to Cloudflares API IP Details

Example:

    public function handle()
    {
        $this->cloudflare->listIPs();
    }

Getters/Setters

If you will be not setting the zone within your environment, you can set your zone ID in the code. This is great if managing multiple zones within Laravel.

setZoneId

  • string $zoneId

Example:

    public function handle()
    {
        $this->cloudflare->setZoneId('o8796t79rf7896479f6497')->getRecordDetails('235b53n5b4314523523');
    }

getZoneId

Returns the zone ID you will be making the custom calls with.

Example:

    public function handle()
    {
        echo $this->cloudflare->getZoneId();
    }