diff --git a/README.md b/README.md index d828f29..9aa2adb 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,11 @@ Install via composer composer require victor-falcon/laravel-task ``` -## Usage +## Usage ### 1. Basic usage Create a simple task using: -``` +```bash artisan task:make Shop/CreateUserShop ``` @@ -130,6 +130,13 @@ $product = CreateProduct::trigger()->withValid($data)->result(); ## Generate IDE Help In order to make more easy to write and use your task you can generate a `_ide_helper_tasks.php` file automatically with the `artisan task:ide-help` command. +## Update config +If you want, you can publish the package config to customize, for example, where do you want you task to be store at: + +```shell +artisan vendor:publish --tag=laravel-task +``` + ## Credits - [Víctor Falcón](https://github.com/victor-falcon) diff --git a/src/Console/Commands/MakeTaskCommand.php b/src/Console/Commands/MakeTaskCommand.php index cf9b739..5c15da0 100644 --- a/src/Console/Commands/MakeTaskCommand.php +++ b/src/Console/Commands/MakeTaskCommand.php @@ -24,6 +24,11 @@ protected function getPath($name) } protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.'\\'.$this->getDefaultPath(); + } + + protected function getDefaultPath(): string { $default = config('laravel-task.folders', 'app/Tasks'); if (is_array($default)) { @@ -32,6 +37,6 @@ protected function getDefaultNamespace($rootNamespace) $default = Str::replaceFirst('app/', '', $default); - return is_dir(app_path($default)) ? $rootNamespace.'\\'.$default : $rootNamespace; + return $default; } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 7b2090e..b741782 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -13,7 +13,7 @@ public function boot() { $this->publishes([ self::CONFIG_PATH => config_path('laravel-task.php'), - ], 'config'); + ], ['config', 'laravel-task']); if ($this->app->runningInConsole()) { $this->commands([