ldc-boutique-cnc/app/Console/Commands/SyncThemeSettings.php
2023-03-09 11:58:40 +01:00

51 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Enums\GeneralConfigType;
use App\Models\Site\GeneralConfig;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
class SyncThemeSettings extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'config:sync_theme';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Synchronize theme config with database.';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
// * Force config clearance.
Artisan::call('config:clear');
// * Force cache to be cleared ( reload GeneralConfigs )
Artisan::call('cache:clear');
// * Fetch or create theme config
/** @var \App\Models\Site\GeneralConfig */
$config = GeneralConfig::query()->where('type', GeneralConfigType::theme())->firstOrNew();
// * Fetch Bo Theme Settings.
$data = config('theme.bo_theme_settings');
$config->data = $data;
$config->saveOrFail();
$this->info('Theme config is overrided with the latest theme.config.php content.');
}
}