File tree Expand file tree Collapse file tree 3 files changed +10
-16
lines changed
Expand file tree Collapse file tree 3 files changed +10
-16
lines changed Original file line number Diff line number Diff line change 11<?php
22
33namespace Backpack \Generators \Console \Commands \Traits ;
4+ use Illuminate \Support \Str ;
45
56trait PublishableStubTrait
67{
78 /**
8- * Check if the stub exists in the project's stubs folder.
9- * If it does, return the path to it.
10- * If it doesn't, return the path to the stub in the package.
11- *
12- * @param string $path
13- * @return string
9+ * Return the path to the stub
1410 */
1511 public function getStubPath (string $ path ): string
1612 {
17- if (file_exists (base_path ("stubs/backpack/generators/ {$ path }.stub " ))) {
18- return base_path ("stubs/backpack/generators/ {$ path }.stub " );
13+ $ path = Str::finish ($ path , '.stub ' );
14+
15+ if (file_exists (base_path ("stubs/backpack/generators/ {$ path }" ))) {
16+ return base_path ("stubs/backpack/generators/ {$ path }" );
1917 }
2018
21- return __DIR__ ."/../../stubs/ {$ path }.stub " ;
19+ return __DIR__ ."/../../stubs/ {$ path }" ;
2220 }
2321}
Original file line number Diff line number Diff line change 99abstract class PublishOrCreateViewBackpackCommand extends GeneratorCommand
1010{
1111 use \Backpack \CRUD \app \Console \Commands \Traits \PrettyCommandOutput;
12+ use \Backpack \Generators \Console \Commands \Traits \PublishableStubTrait;
1213
1314 /**
1415 * The source file to copy from.
@@ -41,12 +42,7 @@ abstract class PublishOrCreateViewBackpackCommand extends GeneratorCommand
4142 */
4243 protected function getStub ()
4344 {
44- // check if base_path('stubs/backpack/generators/$FILE') exists, and use that
45- if (file_exists (base_path ('stubs/backpack/generators/generators/ ' .$ this ->stub ))) {
46- return base_path ('stubs/backpack/generators/generators/ ' .$ this ->stub );
47- }
48-
49- return __DIR__ .'/../../stubs/ ' .$ this ->stub ;
45+ return $ this ->getStubPath ($ this ->stub );
5046 }
5147
5248 /**
Original file line number Diff line number Diff line change @@ -55,6 +55,6 @@ public function boot(): void
5555
5656 $ this ->publishes ([
5757 __DIR__ .'/Console/stubs ' => base_path ('stubs/backpack/generators ' ),
58- ], 'stubs ' );
58+ ], 'backpack-generators- stubs ' );
5959 }
6060}
You can’t perform that action at this time.
0 commit comments