public function handle()
{
$this->crudName = $this->argument('name');
$this->locales = explode(',', $this->option('locales'));
$fields = $this->option('fields');
$fieldsArray = explode(';', $fields);
$this->formFields = array();
if ($fields) {
$x = 0;
foreach ($fieldsArray as $item) {
$itemArray = explode('#', $item);
$this->formFields[$x]['name'] = trim($itemArray[0]);
$this->formFields[$x]['type'] = trim($itemArray[1]);
$this->formFields[$x]['required'] = isset($itemArray[2]) && (trim($itemArray[2]) == 'req' || trim($itemArray[2]) == 'required') ? true : false;
$x++;
}
}
foreach ($this->locales as $locale) {
$locale = trim($locale);
$path = config('view.paths')[0] . '/../lang/' . $locale . '/';
//create directory for locale
if (!File::isDirectory($path)) {
File::makeDirectory($path, 0755, true);
}
$langFile = $this->viewDirectoryPath . 'lang.stub';
$newLangFile = $path . $this->crudName . '.php';
if (!File::copy($langFile, $newLangFile)) {
echo "failed to copy {$langFile}...\n";
} else {
$this->templateVars($newLangFile);
}
$this->info('Lang [' . $locale . '] created successfully.');
}
}