61 lines
1.4 KiB
PHP
61 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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|