@@ 8-71 (lines=64) @@ | ||
5 | use Illuminate\Support\Facades\Config; |
|
6 | use Illuminate\Console\GeneratorCommand; |
|
7 | ||
8 | class CustomRuleMakeCommand extends GeneratorCommand |
|
9 | { |
|
10 | /** |
|
11 | * The console command signature. |
|
12 | * |
|
13 | * @var string |
|
14 | */ |
|
15 | protected $signature = 'adr:rule {name}'; |
|
16 | ||
17 | /** |
|
18 | * The console command description. |
|
19 | * |
|
20 | * @var string |
|
21 | */ |
|
22 | protected $description = 'Create a new Custom Rule'; |
|
23 | ||
24 | /** |
|
25 | * The type of class being generated. |
|
26 | * |
|
27 | * @var string |
|
28 | */ |
|
29 | protected $type = 'Custom Rule'; |
|
30 | ||
31 | /** |
|
32 | * Get the stub file for the generator. |
|
33 | * |
|
34 | * @return string |
|
35 | */ |
|
36 | protected function getStub() |
|
37 | { |
|
38 | return __DIR__.'/stubs/custom-rule.stub'; |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * Get the default namespace for the class. |
|
43 | * |
|
44 | * @param string $rootNamespace |
|
45 | * |
|
46 | * @return string |
|
47 | */ |
|
48 | protected function getDefaultNamespace($rootNamespace) |
|
49 | { |
|
50 | $namespace = studly_case(trim(Config::get('valid.rules.namespace'))); |
|
51 | ||
52 | return $namespace ? $rootNamespace.'\\'.$namespace : $rootNamespace; |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * Get the desired class name from the input. |
|
57 | * |
|
58 | * @return string |
|
59 | */ |
|
60 | protected function getNameInput() |
|
61 | { |
|
62 | $input = studly_case(trim($this->argument('name'))); |
|
63 | $ruleSuffix = Config::get('valid.rules.suffix'); |
|
64 | ||
65 | if (Config::get('valid.rules.override_duplicate_suffix')) { |
|
66 | return str_finish($input, $ruleSuffix); |
|
67 | } |
|
68 | ||
69 | return $input.$ruleSuffix; |
|
70 | } |
|
71 | } |
|
72 |
@@ 8-71 (lines=64) @@ | ||
5 | use Illuminate\Support\Facades\Config; |
|
6 | use Illuminate\Console\GeneratorCommand; |
|
7 | ||
8 | class FormRequestMakeCommand extends GeneratorCommand |
|
9 | { |
|
10 | /** |
|
11 | * The console command signature. |
|
12 | * |
|
13 | * @var string |
|
14 | */ |
|
15 | protected $signature = 'adr:request {name}'; |
|
16 | ||
17 | /** |
|
18 | * The console command description. |
|
19 | * |
|
20 | * @var string |
|
21 | */ |
|
22 | protected $description = 'Create a new Custom FormRequest'; |
|
23 | ||
24 | /** |
|
25 | * The type of class being generated. |
|
26 | * |
|
27 | * @var string |
|
28 | */ |
|
29 | protected $type = 'Custom FormRequest'; |
|
30 | ||
31 | /** |
|
32 | * Get the stub file for the generator. |
|
33 | * |
|
34 | * @return string |
|
35 | */ |
|
36 | protected function getStub() |
|
37 | { |
|
38 | return __DIR__.'/stubs/custom-request.stub'; |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * Get the default namespace for the class. |
|
43 | * |
|
44 | * @param string $rootNamespace |
|
45 | * |
|
46 | * @return string |
|
47 | */ |
|
48 | protected function getDefaultNamespace($rootNamespace) |
|
49 | { |
|
50 | $namespace = studly_case(trim(Config::get('valid.requests.namespace'))); |
|
51 | ||
52 | return $namespace ? $rootNamespace.'\\'.$namespace : $rootNamespace; |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * Get the desired class name from the input. |
|
57 | * |
|
58 | * @return string |
|
59 | */ |
|
60 | protected function getNameInput() |
|
61 | { |
|
62 | $input = studly_case(trim($this->argument('name'))); |
|
63 | $requestSuffix = Config::get('valid.requests.suffix'); |
|
64 | ||
65 | if (Config::get('valid.requests.override_duplicate_suffix')) { |
|
66 | return str_finish($input, $requestSuffix); |
|
67 | } |
|
68 | ||
69 | return $input.$requestSuffix; |
|
70 | } |
|
71 | } |
|
72 |