File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed
src/Illuminate/Foundation Expand file tree Collapse file tree 3 files changed +92
-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 CastMakeCommand extends GeneratorCommand
8+ {
9+ /**
10+ * The console command name.
11+ *
12+ * @var string
13+ */
14+ protected $ name = 'make:cast ' ;
15+
16+ /**
17+ * The console command description.
18+ *
19+ * @var string
20+ */
21+ protected $ description = 'Create a new cast mutator ' ;
22+
23+ /**
24+ * The type of class being generated.
25+ *
26+ * @var string
27+ */
28+ protected $ type = 'Cast ' ;
29+
30+ /**
31+ * Get the stub file for the generator.
32+ *
33+ * @return string
34+ */
35+ protected function getStub ()
36+ {
37+ return __DIR__ .'/stubs/cast.stub ' ;
38+ }
39+
40+ /**
41+ * Get the default namespace for the class.
42+ *
43+ * @param string $rootNamespace
44+ *
45+ * @return string
46+ */
47+ protected function getDefaultNamespace ($ rootNamespace )
48+ {
49+ return $ rootNamespace .'\Casts ' ;
50+ }
51+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace DummyNamespace;
4+
5+ use Illuminate\Contracts\Database\Eloquent\Castable;
6+
7+ class DummyClass implements Castable
8+ {
9+ /**
10+ * Get a given attribute from the model.
11+ *
12+ * @param mixed $value
13+ *
14+ * @return mixed
15+ */
16+ public function get($value)
17+ {
18+ return $value;
19+ }
20+
21+ /**
22+ * Set a given attribute on the model.
23+ *
24+ * @param mixed $value
25+ *
26+ * @return mixed
27+ */
28+ public function set($value)
29+ {
30+ return $value;
31+ }
32+ }
Original file line number Diff line number Diff line change 1313use Illuminate \Database \Console \Seeds \SeedCommand ;
1414use Illuminate \Database \Console \Seeds \SeederMakeCommand ;
1515use Illuminate \Database \Console \WipeCommand ;
16+ use Illuminate \Foundation \Console \CastMakeCommand ;
1617use Illuminate \Foundation \Console \ChannelMakeCommand ;
1718use Illuminate \Foundation \Console \ClearCompiledCommand ;
1819use Illuminate \Foundation \Console \ConfigCacheCommand ;
@@ -130,6 +131,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
130131 'MailMake ' => 'command.mail.make ' ,
131132 'MiddlewareMake ' => 'command.middleware.make ' ,
132133 'ModelMake ' => 'command.model.make ' ,
134+ 'CastMake ' => 'command.cast.make ' ,
133135 'NotificationMake ' => 'command.notification.make ' ,
134136 'NotificationTable ' => 'command.notification.table ' ,
135137 'ObserverMake ' => 'command.observer.make ' ,
@@ -486,6 +488,13 @@ protected function registerModelMakeCommand()
486488 });
487489 }
488490
491+ protected function registerCastMakeCommand ()
492+ {
493+ $ this ->app ->singleton ('command.cast.make ' , function ($ app ) {
494+ return new CastMakeCommand ($ app ['files ' ]);
495+ });
496+ }
497+
489498 /**
490499 * Register the command.
491500 *
You can’t perform that action at this time.
0 commit comments