hustoj /
hustoj-neo
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Console\Commands; |
||
| 4 | |||
| 5 | use App\Exceptions\ApiException; |
||
| 6 | use App\Services\JudgerService; |
||
| 7 | use Illuminate\Console\Command; |
||
| 8 | |||
| 9 | class CreateNewJudger extends Command |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The name and signature of the console command. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $signature = 'judger:new {name}'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The console command description. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $description = 'create new judger'; |
||
| 24 | |||
| 25 | public function handle() |
||
| 26 | { |
||
| 27 | $name = $this->argument('name'); |
||
| 28 | if ($name) { |
||
| 29 | try { |
||
| 30 | $judger = app(JudgerService::class)->newJudger($name); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 31 | $this->info("Create New Judger {$name}, Code: ".$judger->code); |
||
| 32 | } catch (ApiException $e) { |
||
| 33 | $this->error($e->getMessage()); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 |