1 | <?php |
||
12 | class ControllerCommand extends Command |
||
13 | { |
||
14 | /** |
||
15 | * The name of command. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $name = 'starter:resource'; |
||
20 | |||
21 | /** |
||
22 | * The description of command. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $description = 'Create a new RESTfull controller.'; |
||
27 | |||
28 | /** |
||
29 | * The type of class being generated. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $type = 'Controller'; |
||
34 | |||
35 | /** |
||
36 | * Execute the command. |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
40 | public function fire() |
||
41 | { |
||
42 | try { |
||
43 | (new ControllerGenerator([ |
||
44 | 'name' => $this->argument('name'), |
||
45 | 'force' => $this->option('force'), |
||
46 | ]))->run(); |
||
47 | $this->info($this->type.' created successfully.'); |
||
48 | } catch (FileAlreadyExistsException $e) { |
||
49 | $this->error($this->type.' already exists!'); |
||
50 | |||
51 | //return false; |
||
52 | } |
||
53 | |||
54 | (new RoutesGenerator([ |
||
55 | 'name' => $this->argument('name'), |
||
56 | 'force' => $this->option('force'), |
||
57 | ]))->run(); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * The array of command arguments. |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | public function getArguments() |
||
76 | |||
77 | /** |
||
78 | * The array of command options. |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | public function getOptions() |
||
94 | } |
||
95 |