88use Illuminate \Support \Facades \File ;
99use Illuminate \Support \Str ;
1010use Symfony \Component \Console \Attribute \AsCommand ;
11- use Symfony \Component \Console \Input \InputInterface ;
12- use Symfony \Component \Console \Output \OutputInterface ;
1311
1412use function Laravel \Prompts \search ;
15- use function Laravel \Prompts \select ;
1613
1714#[AsCommand('module:model-show ' , 'Show information about an Eloquent model in modules ' )]
1815class ModelShowCommand extends ShowModelCommand implements PromptsForMissingInput
@@ -40,32 +37,6 @@ class ModelShowCommand extends ShowModelCommand implements PromptsForMissingInpu
4037 {--database= : The database connection to use}
4138 {--json : Output the model as JSON} ' ;
4239
43- /**
44- * Qualify the given model class base name.
45- *
46- * @see \Illuminate\Console\GeneratorCommand
47- */
48- protected function qualifyModel (string $ model ): string
49- {
50- if (str_contains ($ model , '\\' ) && class_exists ($ model )) {
51- return $ model ;
52- }
53-
54- $ modelPaths = $ this ->findModels ($ model );
55-
56- if ($ modelPaths ->count () == 0 ) {
57- return $ model ;
58- } elseif ($ modelPaths ->count () == 1 ) {
59- return $ this ->formatModuleNamespace ($ modelPaths ->first ());
60- }
61-
62- return select (
63- label: 'Select Model ' ,
64- options: $ modelPaths ,
65- required: 'You must select at least one model ' ,
66- );
67- }
68-
6940 private function formatModuleNamespace (string $ path ): string
7041 {
7142 return
@@ -90,22 +61,19 @@ public function findModels(string $model): Collection
9061 ->map ($ this ->formatModuleNamespace (...));
9162 }
9263
93- protected function promptForMissingArguments ( InputInterface $ input , OutputInterface $ output ): void
64+ protected function promptForMissingArgumentsUsing ( ): array
9465 {
95- $ selected_item = search (
96- label: 'Select Model ' ,
97- options: function (string $ search_value ) {
98- return $ this ->findModels (
99- Str::of ($ search_value )->wrap ('' , '* ' )
100- )->toArray ();
101- },
102- placeholder: 'type some thing ' ,
103- required: 'You must select one Model ' ,
104- );
105-
106- $ input ->setArgument (
107- name: 'model ' ,
108- value: $ selected_item
109- );
66+ return [
67+ 'model ' => fn () => search (
68+ label: 'Select Model ' ,
69+ options: function (string $ search_value ) {
70+ return $ this ->findModels (
71+ Str::of ($ search_value )->wrap ('' , '* ' )
72+ )->toArray ();
73+ },
74+ placeholder: 'type some thing ' ,
75+ required: 'You must select one Model ' ,
76+ ),
77+ ];
11078 }
11179}
0 commit comments