This repository was archived by the owner on Jan 11, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Themsaid \Transformers ;
4
+
5
+ use Illuminate \Console \GeneratorCommand ;
6
+
7
+ class MakeTransformerCommand extends GeneratorCommand
8
+ {
9
+ /**
10
+ * The console command name.
11
+ *
12
+ * @var string
13
+ */
14
+ protected $ name = 'make:transformer ' ;
15
+
16
+ /**
17
+ * The console command description.
18
+ *
19
+ * @var string
20
+ */
21
+ protected $ description = 'Create a new transformer class ' ;
22
+
23
+ /**
24
+ * The type of class being generated.
25
+ *
26
+ * @var string
27
+ */
28
+ protected $ type = 'Transformer ' ;
29
+
30
+ /**
31
+ * Get the stub file for the generator.
32
+ *
33
+ * @return string
34
+ */
35
+ protected function getStub ()
36
+ {
37
+ return __DIR__ .'/stubs/transformer.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 .'\Transformers ' ;
49
+ }
50
+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ public function boot()
17
17
$ this ->publishes ([
18
18
__DIR__ . '/config/modelTransformers.php ' => config_path ('modelTransformers.php ' ),
19
19
]);
20
+
21
+ $ this ->commands (MakeTransformerCommand::class);
20
22
}
21
23
/**
22
24
* Register any package services.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DummyNamespace;
4
+
5
+ use Illuminate\Database\Eloquent\Model;
6
+ use Themsaid\Transformers\AbstractTransformer;
7
+
8
+ class DummyClass extends AbstractTransformer
9
+ {
10
+ /**
11
+ * @param Model $model
12
+ * @return array
13
+ */
14
+ public function transformModel(Model $model): array
15
+ {
16
+ //
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments