Skip to content

Commit

Permalink
Merge pull request #56 from iksaku/customizable_stubs
Browse files Browse the repository at this point in the history
feature: Enable stub publishing and customization
  • Loading branch information
danharrin authored Mar 2, 2021
2 parents 13e1d18 + a284391 commit 60ac213
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Commands/Concerns/CanManipulateFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ protected function copyStubToApp($stub, $targetPath, $replacements = [])
{
$filesystem = new Filesystem();

$stub = Str::of($filesystem->get(__DIR__ . "/../../../stubs/{$stub}.stub"));
if (! $this->fileExists($stubPath = base_path("stubs/filament/{$stub}.stub"))) {
$stubPath = __DIR__ . "/../../../stubs/{$stub}.stub";
}

$stub = Str::of($filesystem->get($stubPath));

foreach ($replacements as $key => $replacement) {
$stub = $stub->replace("{{ {$key} }}", $replacement);
Expand Down
4 changes: 4 additions & 0 deletions src/FilamentServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ protected function bootPublishing()
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/filament'),
], 'filament-lang');

$this->publishes([
__DIR__ . '/../stubs' => base_path('stubs/filament'),
], 'filament-stubs');

$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/filament'),
], 'filament-views');
Expand Down

0 comments on commit 60ac213

Please sign in to comment.