1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00
invoiceninja/app/Console/Commands/MakeModule.php
2016-12-08 17:09:45 +02:00

63 lines
1.5 KiB
PHP

<?php
namespace App\Console\Commands;
use Artisan;
use Illuminate\Console\Command;
class MakeModule extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:make-module {name} {fields?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate Module CRUD';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$fields = $this->argument('fields');
$this->info("Creating module: {$name}");
$this->info("Fields: {$fields}");
Artisan::call('module:make', ['name' => [$name]]);
Artisan::call('module:make-migration', ['name' => "create_{$name}_table", '--fields' => $fields, 'module' => $name]);
Artisan::call('module:make-model', ['model' => $name, 'module' => $name]);
Artisan::call('ninja:make-datatable', ['name' => $name, 'module' => $name]);
Artisan::call('ninja:make-repository', ['name' => $name, 'module' => $name]);
}
protected function getArguments()
{
return [
['name', InputArgument::REQUIRED, 'The name of the module.'],
['fields', InputArgument::OPTIONAL, 'The fields of the module.']
];
}
}