From 50d23f34fb05795db637e128f3cdd4453acdf65a Mon Sep 17 00:00:00 2001 From: Jevan Tang <22316055+jevantang@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:43:18 +0800 Subject: [PATCH] chore: stubs --- config/plugins.php | 4 ++-- .../stubs/app/Http/Controllers/setting-controller.stub | 2 +- .../Providers/{provider.stub => service-provider.stub} | 2 +- src/Commands/stubs/app/Providers/sql-provider.stub | 2 +- src/Commands/stubs/plugin.json.stub | 2 +- src/Commands/stubs/routes/api.stub | 4 ++-- src/Commands/stubs/routes/web.stub | 10 +++++----- 7 files changed, 13 insertions(+), 13 deletions(-) rename src/Commands/stubs/app/Providers/{provider.stub => service-provider.stub} (96%) diff --git a/config/plugins.php b/config/plugins.php index 506b06c..69f2a76 100644 --- a/config/plugins.php +++ b/config/plugins.php @@ -91,8 +91,8 @@ 'stubs' => [ 'path' => dirname(__DIR__).'/src/Commands/stubs', 'files' => [ - 'app/Http/Controllers/setting-controller' => 'app/Http/Controllers/$STUDLY_NAME$SettingController.php', - 'app/Providers/provider' => 'app/Providers/$STUDLY_NAME$ServiceProvider.php', + 'app/Http/Controllers/setting-controller' => 'app/Http/Controllers/SettingController.php', + 'app/Providers/service-provider' => 'app/Providers/PluginServiceProvider.php', 'app/Providers/command-provider' => 'app/Providers/CommandServiceProvider.php', 'app/Providers/route-provider' => 'app/Providers/RouteServiceProvider.php', 'config/config' => 'config/$KEBAB_NAME$.php', diff --git a/src/Commands/stubs/app/Http/Controllers/setting-controller.stub b/src/Commands/stubs/app/Http/Controllers/setting-controller.stub index 4832c52..fc93b77 100644 --- a/src/Commands/stubs/app/Http/Controllers/setting-controller.stub +++ b/src/Commands/stubs/app/Http/Controllers/setting-controller.stub @@ -5,7 +5,7 @@ namespace Plugins\$STUDLY_NAME$\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; -class $STUDLY_NAME$SettingController extends Controller +class SettingController extends Controller { public function index(Request $request) { diff --git a/src/Commands/stubs/app/Providers/provider.stub b/src/Commands/stubs/app/Providers/service-provider.stub similarity index 96% rename from src/Commands/stubs/app/Providers/provider.stub rename to src/Commands/stubs/app/Providers/service-provider.stub index aa557f6..d79bb07 100644 --- a/src/Commands/stubs/app/Providers/provider.stub +++ b/src/Commands/stubs/app/Providers/service-provider.stub @@ -10,7 +10,7 @@ namespace $NAMESPACE$\Providers; use Illuminate\Support\ServiceProvider as BaseServiceProvider; -class $STUDLY_NAME$ServiceProvider extends BaseServiceProvider +class PluginServiceProvider extends BaseServiceProvider { /** * Boot the application events. diff --git a/src/Commands/stubs/app/Providers/sql-provider.stub b/src/Commands/stubs/app/Providers/sql-provider.stub index 99b04e3..197a009 100644 --- a/src/Commands/stubs/app/Providers/sql-provider.stub +++ b/src/Commands/stubs/app/Providers/sql-provider.stub @@ -36,7 +36,7 @@ class SqlLogServiceProvider extends ServiceProvider */ protected function registerQueryLogger() { - if (! $this->app['config']->get('app.debug')) { + if (! $this->app['config']->get('app.debug') || $this->app['config']->get('app.env') != 'local') { return; } diff --git a/src/Commands/stubs/plugin.json.stub b/src/Commands/stubs/plugin.json.stub index e9beee8..c5be112 100644 --- a/src/Commands/stubs/plugin.json.stub +++ b/src/Commands/stubs/plugin.json.stub @@ -9,7 +9,7 @@ "accessPath": "/$KEBAB_NAME$", "settingsPath": "/$KEBAB_NAME$/setting", "providers": [ - "$PLUGIN_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider", + "$PLUGIN_NAMESPACE$\\$STUDLY_NAME$\\Providers\\PluginServiceProvider", "$PLUGIN_NAMESPACE$\\$STUDLY_NAME$\\Providers\\RouteServiceProvider" ], "autoloadFiles": [], diff --git a/src/Commands/stubs/routes/api.stub b/src/Commands/stubs/routes/api.stub index 334c100..8e8eabf 100755 --- a/src/Commands/stubs/routes/api.stub +++ b/src/Commands/stubs/routes/api.stub @@ -8,7 +8,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; -use $PLUGIN_NAMESPACE$\$STUDLY_NAME$\Http\Controllers as ApiController; +use $PLUGIN_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\SettingController; /* |-------------------------------------------------------------------------- @@ -22,7 +22,7 @@ use $PLUGIN_NAMESPACE$\$STUDLY_NAME$\Http\Controllers as ApiController; */ // Route::prefix('$KEBAB_NAME$')->name('$KEBAB_NAME$.')->group([], function() { -// Route::get('/', [ApiController\$STUDLY_NAME$SettingController::class, 'index'])->name('index'); +// Route::get('/', [SettingController::class, 'index'])->name('index'); // Route::middleware('auth:api')->get('auth', function (Request $request) { // return $request->user(); diff --git a/src/Commands/stubs/routes/web.stub b/src/Commands/stubs/routes/web.stub index c724a33..4f7eab2 100755 --- a/src/Commands/stubs/routes/web.stub +++ b/src/Commands/stubs/routes/web.stub @@ -7,7 +7,7 @@ */ use Illuminate\Support\Facades\Route; -use $PLUGIN_NAMESPACE$\$STUDLY_NAME$\Http\Controllers as WebController; +use $PLUGIN_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\SettingController; /* |-------------------------------------------------------------------------- @@ -21,15 +21,15 @@ use $PLUGIN_NAMESPACE$\$STUDLY_NAME$\Http\Controllers as WebController; */ Route::prefix('$KEBAB_NAME$')->name('$KEBAB_NAME$.')->group([], function() { - Route::get('/', [WebController\$STUDLY_NAME$SettingController::class, 'index'])->name('index'); - Route::get('settings', [WebController\$STUDLY_NAME$SettingController::class, 'showSettingView'])->name('setting'); - Route::post('setting', [WebController\$STUDLY_NAME$SettingController::class, 'saveSetting'])->name('save.setting'); + Route::get('/', [SettingController::class, 'index'])->name('index'); + Route::get('settings', [SettingController::class, 'showSettingView'])->name('setting'); + Route::post('setting', [SettingController::class, 'saveSetting'])->name('save.setting'); // without VerifyCsrfToken // Route::withoutMiddleware([ // \App\Http\Middleware\EncryptCookies::class, // \App\Http\Middleware\VerifyCsrfToken::class, // ])->group(function() { - // Route::get('example', [WebController\$STUDLY_NAME$SettingController::class, 'index'])->name('example'); + // Route::get('example', [SettingController::class, 'index'])->name('example'); // }); });