33namespace Backpack \Generators \Console \Commands ;
44
55use Illuminate \Console \GeneratorCommand ;
6+ use Illuminate \Support \Str ;
67
78class ButtonBackpackCommand extends GeneratorCommand
89{
10+ use \Backpack \CRUD \app \Console \Commands \Traits \PrettyCommandOutput;
911 /**
1012 * The console command name.
1113 *
@@ -62,8 +64,7 @@ public function handle()
6264 */
6365 public function fire ()
6466 {
65- $ name = $ this ->getNameInput ();
66-
67+ $ name = Str::of ($ this ->getNameInput ());
6768 $ path = $ this ->getPath ($ name );
6869
6970 if ($ this ->alreadyExists ($ this ->getNameInput ())) {
@@ -72,10 +73,14 @@ public function fire()
7273 return false ;
7374 }
7475
75- $ this ->makeDirectory ($ path );
76+ $ this ->infoBlock ("Creating {$ name ->replace ('_ ' , ' ' )->title ()} {$ this ->type }" );
77+ $ this ->progressBlock ("Creating view <fg=blue> $ {path}.blade.php</> " );
7678
79+ $ this ->makeDirectory ($ path );
7780 $ this ->files ->put ($ path , $ this ->buildClass ($ name ));
78-
81+
82+ $ this ->closeProgressBlock ();
83+ $ this ->newLine ();
7984 $ this ->info ($ this ->type .' created successfully. ' );
8085 }
8186
@@ -98,7 +103,7 @@ protected function alreadyExists($name)
98103 */
99104 protected function getPath ($ name )
100105 {
101- return $ this -> laravel [ ' path ' ]. ' /../resources/ views/vendor/backpack/crud/buttons/' . str_replace ( '\\' , ' / ' , $ name). ' . blade.php' ;
106+ return resource_path ( " views/vendor/backpack/crud/buttons/ $ name. blade.php" );
102107 }
103108
104109 /**
0 commit comments