phpvms/app/Console/Commands/YamlExport.php
Nabeel S aedb1f22b6
Don't allow cancels from certain states (#396)
* Don't allow cancels from certain states

* Unused imports

* Don't reset the state doubly

* Move SetUserActive into listener; code cleanup

* Unused imports

* Add missing files into htaccess

* Move Command contract to correct folder
2019-09-16 13:08:26 -04:00

42 lines
873 B
PHP

<?php
namespace App\Console\Commands;
use App\Contracts\Command;
use DB;
use Symfony\Component\Yaml\Yaml;
/**
* Class YamlExport
*/
class YamlExport extends Command
{
protected $signature = 'phpvms:yaml-export {tables*}';
protected $description = 'YAML table export';
/**
* Run dev related commands
*/
public function handle()
{
$tables = $this->argument('tables');
if (empty($tables)) {
$this->error('No tables specified');
exit();
}
$export_tables = [];
foreach ($tables as $table) {
$export_tables[$table] = [];
$rows = DB::table($table)->get();
foreach ($rows as $row) {
$export_tables[$table][] = (array) $row;
}
}
$yaml = Yaml::dump($export_tables, 4, 2);
echo $yaml;
}
}