akaunting/app/Console/Commands/CompanySeed.php

51 lines
1.2 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
2020-02-07 12:44:26 +03:00
use Symfony\Component\Console\Input\InputOption;
2017-09-14 22:21:00 +03:00
class CompanySeed extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
2020-02-07 12:44:26 +03:00
protected $signature = 'company:seed {company} {--class= : with Fully Qualified Name}';
2017-09-14 22:21:00 +03:00
/**
* The console command description.
*
* @var string
*/
2020-02-07 12:44:26 +03:00
protected $description = 'Run one or all seeds for a specific company';
2020-02-03 18:57:31 +03:00
2017-09-14 22:21:00 +03:00
/**
2020-02-07 12:44:26 +03:00
* Execute the console command.
2017-09-14 22:21:00 +03:00
*
2020-02-07 12:44:26 +03:00
* @return mixed
* @throws \Illuminate\Contracts\Container\BindingResolutionException
2017-09-14 22:21:00 +03:00
*/
2020-02-07 12:44:26 +03:00
public function handle()
2017-09-14 22:21:00 +03:00
{
2020-02-07 12:44:26 +03:00
$class_name = $this->input->getOption('class') ?? 'Database\Seeds\Company';
$class = $this->laravel->make($class_name);
$class->setContainer($this->laravel)->setCommand($this)->__invoke();
2017-09-14 22:21:00 +03:00
}
/**
2020-02-07 12:44:26 +03:00
* Get the console command options.
2017-09-14 22:21:00 +03:00
*
2020-02-07 12:44:26 +03:00
* @return array
2017-09-14 22:21:00 +03:00
*/
2020-02-07 12:44:26 +03:00
protected function getOptions()
2017-09-14 22:21:00 +03:00
{
2020-02-07 12:44:26 +03:00
return [
['class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', 'Database\Seeds\Company'],
];
2017-09-14 22:21:00 +03:00
}
}