File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 1717 "require" : {},
1818 "extra" : {
1919 "laravel" : {
20+ "providers" : [
21+ " \\ SalemC\\ TypeScriptifyLaravelModels\\ Providers\\ TypeScriptifyModelsServiceProvider"
22+ ],
2023 "aliases" : {
2124 "TypeScriptifyModel" : " SalemC\\ TypeScriptifyLaravelModels\\ TypeScriptifyModel"
2225 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SalemC \TypeScriptifyLaravelModels \Commands ;
4+
5+ use Illuminate \Console \Command ;
6+
7+ use SalemC \TypeScriptifyLaravelModels \TypeScriptifyModel ;
8+
9+ class TypeScriptifyModelCommand extends Command {
10+ /**
11+ * The name and signature of the console command.
12+ *
13+ * @var string
14+ */
15+ protected $ signature = 'typescriptify:model {model : The fully qualified class name for the model - e.g. App\Models\User} ' ;
16+
17+ /**
18+ * The console command description.
19+ *
20+ * @var string
21+ */
22+ protected $ description = 'Convert a model to it \'s TypeScript definition. ' ;
23+
24+ /**
25+ * Execute the console command.
26+ *
27+ * @return int
28+ */
29+ public function handle () {
30+ echo TypeScriptifyModel::generate ($ this ->argument ('model ' ));
31+
32+ return Command::SUCCESS ;
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SalemC \TypeScriptifyLaravelModels \Providers ;
4+
5+ use Illuminate \Support \ServiceProvider ;
6+
7+ use SalemC \TypeScriptifyLaravelModels \Commands \TypeScriptifyModelCommand ;
8+
9+ class TypeScriptifyModelsServiceProvider extends ServiceProvider {
10+ /**
11+ * Register all commands.
12+ *
13+ * @return void
14+ */
15+ private function registerCommands (): void {
16+ if (!$ this ->app ->runningInConsole ()) return ;
17+
18+ $ this ->commands ([
19+ TypeScriptifyModelCommand::class,
20+ ]);
21+ }
22+
23+ /**
24+ * Bootstrap services.
25+ *
26+ * @return void
27+ */
28+ public function boot (): void {
29+ $ this ->registerCommands ();
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments