Skip to content

Commit

Permalink
Start work on clear command
Browse files Browse the repository at this point in the history
  • Loading branch information
robdekort committed Oct 24, 2021
1 parent 9ef4c90 commit 05498b6
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions dev/app/Console/Commands/ClearSite.php
@@ -0,0 +1,66 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Statamic\Console\RunsInPlease;
use Statamic\Facades\Entry;

class ClearSite extends Command
{
use RunsInPlease;

/**
* The name of the console command.
*
* @var string
*/
protected $name = 'peak:clear-site';

/**
* The console command description.
*
* @var string
*/
protected $description = "Clear all default Peak content.";

/**
* Execute the console command.
*
* @return bool|null
*/
public function handle()
{
$clear_site = ($this->confirm('Are you sure you want to clear all content?', true)) ? true : false;

if ($clear_site) {
$this->clearPageBuilder('/');
$this->trashPages('/');
Artisan::call('cache:clear');
$this->info("Your site is clear.");
}
}

/**
* Clear the page builder.
*
* @return bool|null
*/
protected function clearPageBuilder($uri)
{
Entry::findByUri($uri)
->set('page_builder', null)
->save();
}

/**
* Trash all pages but home.
*
* @return bool|null
*/
protected function trashPages()
{

}
}

0 comments on commit 05498b6

Please sign in to comment.