Skip to content

Commit

Permalink
chore: make publish command working for views and config file
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalinfyom committed Apr 10, 2021
1 parent c972804 commit a59fcfe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Publish the config files and view files :

```
php artisan laravel-payumoney:publish
php vendor:publish --provider="InfyOm\Payu\PayuMoneyAppServiceProvider" --tag="config
php vendor:publish --provider="InfyOm\Payu\PayuMoneyAppServiceProvider" --tag="views
```

Note: Above command will publish following files
Expand Down
20 changes: 15 additions & 5 deletions src/Commands/PublishAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace InfyOm\Payu\Commands;

use Illuminate\Support\Facades\File;

/**
* Class PublishAsset
*/
Expand All @@ -23,14 +25,23 @@ class PublishAsset extends \Illuminate\Console\Command

public function handle()
{
// publish view

$this->info('payu.php config file published.');
\Artisan::call('vendor:publish --provider="InfyOm\Payu\PayuMoneyAppServiceProvider" --tag="config"');
$config = file_get_contents(__DIR__.'./../../config/payu.php');
$this->createFile(config_path('/'), 'payu.php', $config);

$this->info('view files published.');
\Artisan::call('vendor:publish --provider="InfyOm\Payu\PayuMoneyAppServiceProvider" --tag="views"');

$this->info('view files published.');
$views = file_get_contents(__DIR__.'./../../config/payu.php');
if (!\File::isDirectory(resource_path('views/payumoney'))) {
\File::makeDirectory(resource_path('views/payumoney/'));
}

\File::copyDirectory(
base_path('vendor/infyomlabs/laravel-payumoney/views/payumoney'),
resource_path('views/payumoney')
);

$this->info('PayuMoneyController published.');
$templateData = file_get_contents(__DIR__.'/../../stubs/PayuMoneyController.stub');

Expand All @@ -47,5 +58,4 @@ public static function createFile($path, $fileName, $contents)

file_put_contents($path, $contents);
}

}
5 changes: 0 additions & 5 deletions src/PayuMoneyAppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ public function boot()
__DIR__.'/../config/payu.php' => config_path('payu.php')
], 'config');

// publish files
$this->publishes([
__DIR__.'/../views' => resource_path('views/payumoney')], 'views');

$this->loadViewsFrom(__DIR__.'/../views', 'payumoney');
$this->loadRoutesFrom(__DIR__.'/routes.php');
}

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit a59fcfe

Please sign in to comment.