ldc-boutique-cnc/app/Console/Commands/CreateThemeSettings.php
Olivier Legat 421fe33763 make themable
execute php artisan migrate to get theme_settings table
new commande available = create:theme-settings {theme_name?} Initialise les settings pour un nouveau theme
positionnement des blades dans un dossier défini par la nouvelle variable d'environnement APP_THEME (default : basic)
positionnement des ressources js et sass dans le dossier des blades du theme (pour mettre toute l'arboresence necessaire au thème sous une seule racine gitable)
2021-03-05 11:37:13 +01:00

60 lines
1.4 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\ThemeSettings;
use Illuminate\Console\Command;
class CreateThemeSettings extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'create:theme-settings {theme_name?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Initialise les settings pour un nouveau theme';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$theme_name = $this->argument('theme_name');
if(!$theme_name) {
$theme_name = $this->ask('theme name ?');
}
$bSettingExists = ThemeSettings::where('theme_name','=',$theme_name)->exists();
if($bSettingExists) {
$this->info('Settings for '.$theme_name. ' already exists.');
} else {
$theme_setting = new ThemeSettings();
$theme_setting->theme_name = $theme_name;
$theme_setting->site_name = "Nom du site";
$theme_setting->company = "Société";
$theme_setting->save();
$this->info('Settings created for '.$theme_name);
}
}
}