phpvms/app/Console/Commands/YamlExport.php
Nabeel S 23eb9dcbda
384 Laravel 6 changes (#385)
* 384 Laravel 6 changes

* Library versions

* Update package versions

* Add keyType to models

* Remove unused dependencies

* StyleCI fixes

* Fix models for test

* Fix tests output and update test runner

* Unused imports

* Update exceptions handler

* Fix login page
2019-09-13 08:05:02 -04:00

42 lines
871 B
PHP

<?php
namespace App\Console\Commands;
use App\Console\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;
}
}