Skip to content

Commit 13d53c0

Browse files
authored
Add option to publish stub files (#15)
* Add option to publish stub files * Fix styling
1 parent ffd3c43 commit 13d53c0

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ return [
6969
];
7070
```
7171

72+
You can publish the stub files with:
73+
74+
```bash
75+
php artisan vendor:publish --tag="rbac-stubs"
76+
```
77+
7278
## Usage
7379

7480
```bash

src/Commands/AbilityMakeCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class AbilityMakeCommand extends GeneratorCommand
2626
*/
2727
protected function getStub()
2828
{
29-
return __DIR__.'/../../stubs/ability.stub';
29+
return file_exists($customPath = base_path('/stubs/ability.stub'))
30+
? $customPath
31+
: __DIR__.'/../../stubs/ability.stub';
3032
}
3133

3234
/**

src/Commands/DefinedRoleMakeCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class DefinedRoleMakeCommand extends GeneratorCommand
2525
*/
2626
protected function getStub()
2727
{
28-
return __DIR__.'/../../stubs/defined-role.stub';
28+
return file_exists($customPath = base_path('/stubs/defined-role.stub'))
29+
? $customPath
30+
: __DIR__.'/../../stubs/defined-role.stub';
2931
}
3032

3133
/**

src/RbacServiceProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ public function configurePackage(Package $package): void
2323
]);
2424
}
2525

26+
public function packageBooted()
27+
{
28+
parent::packageBooted();
29+
30+
$this->publishes([
31+
__DIR__.'/../stubs/ability.stub' => base_path('stubs/ability.stub'),
32+
__DIR__.'/../stubs/defined-role.stub' => base_path('stubs/defined-role.stub'),
33+
], ['rbac-stubs', 'stubs']);
34+
}
35+
2636
/**
2737
* @return void
2838
*/

0 commit comments

Comments
 (0)