Skip to content

Commit

Permalink
because of cloudflare
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Dec 13, 2023
1 parent d020ddc commit 9de722c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/Commands/CloudflarePurge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Grafite\Support\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;

class CloudflarePurge extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'cloudflare:purge {zone} {email} {key}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Purge the Cloudflare cache';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Http::delete('https://api.cloudflare.com/client/v4/zones/'.$this->argument('zone').'/purge_cache', [
'purge_everything' => true,
], [
'X-Auth-Email' => $this->argument('email'),
'X-Auth-Key' => $this->argument('key'),
'Content-Type' => 'application/json',
]);

$this->info('Purged.');

return 0;
}
}
5 changes: 4 additions & 1 deletion src/SupportProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\ServiceProvider;
use Grafite\Support\Commands\CloudflarePurge;

class SupportProvider extends ServiceProvider
{
Expand Down Expand Up @@ -50,6 +51,8 @@ public function boot()
*/
public function register()
{
//
$this->commands([
CloudflarePurge::class,
]);
}
}

0 comments on commit 9de722c

Please sign in to comment.