@@ -12,7 +12,7 @@ class LicenseUpdate extends Command
1212 *
1313 * @var string
1414 */
15- protected $ signature = 'license:update ' ;
15+ protected $ signature = 'license:update {--quantity=?} {--license=?} {--owner_type=?} {--owner_id=?} ' ;
1616
1717 /**
1818 * The console command description.
@@ -45,7 +45,7 @@ public function handle()
4545
4646 protected function getQuantity ($ current = 0 )
4747 {
48- return intval ($ this ->ask ("Please select a new maximum value for this license. (The current maximum is {$ current }) " ));
48+ return intval ($ this ->option ( " quantity " ) ?: $ this -> ask ("Please select a new maximum value for this license. (The current maximum is {$ current }) " ));
4949 }
5050
5151 protected function selectLicense ($ where = [])
@@ -65,15 +65,19 @@ protected function selectOwnerId($where = [])
6565
6666 final protected function getSelection ($ column , $ where = [])
6767 {
68- try {
69- $ options = DB ::table ('licenses ' )->where ($ where )->groupBy ($ column )->get ([$ column ])->pluck ($ column )->toArray ();
70- if (count ($ options ) > 1 ) {
71- $ selection = $ this ->choice ("Select a {$ column }" , $ options );
72- } else {
73- $ selection = $ options [0 ];
68+ $ selection = $ this ->option ($ column ) ?: null ;
69+
70+ if (!$ selection ) {
71+ try {
72+ $ options = DB ::table ('licenses ' )->where ($ where )->groupBy ($ column )->get ([$ column ])->pluck ($ column )->toArray ();
73+ if (count ($ options ) > 1 ) {
74+ $ selection = $ this ->choice ("Select a {$ column }" , $ options );
75+ } else {
76+ $ selection = $ options [0 ];
77+ }
78+ } catch (\OutOfBoundsException $ e ) {
79+ throw new \Exception ("Could not find a {$ column }" , 1 , $ e );
7480 }
75- } catch (\OutOfBoundsException $ e ) {
76- throw new \Exception ("Could not find a {$ column }" , 1 , $ e );
7781 }
7882
7983 $ this ->info ("Selected: {$ selection }" );
0 commit comments