File tree Expand file tree Collapse file tree 3 files changed +104
-0
lines changed
src/Illuminate/Foundation Expand file tree Collapse file tree 3 files changed +104
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Illuminate \Foundation \Console ;
4+
5+ use Illuminate \Console \GeneratorCommand ;
6+
7+ class RuleMakeCommand extends GeneratorCommand
8+ {
9+ /**
10+ * The console command name.
11+ *
12+ * @var string
13+ */
14+ protected $ name = 'make:rule ' ;
15+
16+ /**
17+ * The console command description.
18+ *
19+ * @var string
20+ */
21+ protected $ description = 'Create a new validation rule ' ;
22+
23+ /**
24+ * The type of class being generated.
25+ *
26+ * @var string
27+ */
28+ protected $ type = 'Rule ' ;
29+
30+ /**
31+ * Get the stub file for the generator.
32+ *
33+ * @return string
34+ */
35+ protected function getStub ()
36+ {
37+ return __DIR__ .'/stubs/rule.stub ' ;
38+ }
39+
40+ /**
41+ * Get the default namespace for the class.
42+ *
43+ * @param string $rootNamespace
44+ * @return string
45+ */
46+ protected function getDefaultNamespace ($ rootNamespace )
47+ {
48+ return $ rootNamespace .'\Rules ' ;
49+ }
50+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace DummyNamespace;
4+
5+ use Illuminate\Contracts\Validation\Rule;
6+
7+ class DummyClass implements Rule
8+ {
9+ /**
10+ * Create a new rule instance.
11+ *
12+ * @return void
13+ */
14+ public function __construct()
15+ {
16+ //
17+ }
18+
19+ /**
20+ * Determine if the validation rule passes.
21+ *
22+ * @param string $attribute
23+ * @param mixed $value
24+ * @return bool
25+ */
26+ public function passes($attribute, $value)
27+ {
28+ //
29+ }
30+
31+ /**
32+ * Get the validation error message.
33+ *
34+ * @return string
35+ */
36+ public function message()
37+ {
38+ return 'The validation error message.';
39+ }
40+ }
Original file line number Diff line number Diff line change 1414use Illuminate \Queue \Console \FailedTableCommand ;
1515use Illuminate \Foundation \Console \AppNameCommand ;
1616use Illuminate \Foundation \Console \JobMakeCommand ;
17+ use Illuminate \Foundation \Console \RuleMakeCommand ;
1718use Illuminate \Database \Console \Seeds \SeedCommand ;
1819use Illuminate \Foundation \Console \MailMakeCommand ;
1920use Illuminate \Foundation \Console \OptimizeCommand ;
@@ -144,6 +145,7 @@ class ArtisanServiceProvider extends ServiceProvider
144145 'QueueFailedTable ' => 'command.queue.failed-table ' ,
145146 'QueueTable ' => 'command.queue.table ' ,
146147 'RequestMake ' => 'command.request.make ' ,
148+ 'RuleMake ' => 'command.rule.make ' ,
147149 'SeederMake ' => 'command.seeder.make ' ,
148150 'SessionTable ' => 'command.session.table ' ,
149151 'Serve ' => 'command.serve ' ,
@@ -725,6 +727,18 @@ protected function registerRequestMakeCommand()
725727 });
726728 }
727729
730+ /**
731+ * Register the command.
732+ *
733+ * @return void
734+ */
735+ protected function registerRuleMakeCommand ()
736+ {
737+ $ this ->app ->singleton ('command.rule.make ' , function ($ app ) {
738+ return new RuleMakeCommand ($ app ['files ' ]);
739+ });
740+ }
741+
728742 /**
729743 * Register the command.
730744 *
You can’t perform that action at this time.
0 commit comments