diff --git a/README.md b/README.md index cf1e8fa..0ed9661 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,18 @@ Laravel 7+ stub files more consistent with PSR-12 / PHP 7+ - Version 1.x is aimed at Laravel 7 and PHP 7 - Version 2.x is aimed at Laravel 8+ and PHP 8 + +# Usage + +To install the stubs, run the following command: +```bash +php artisan coddin-stubs:install +``` +> **Note:** This will not overwrite existing stub files + +To update the stubs, run the following command: + +```bash +php artisan coddin-stubs:update +``` +> **Note:** This will overwrite existing stub files. Custom stubs will not be overwritten. \ No newline at end of file diff --git a/composer.json b/composer.json index b9ca8a8..d62bf13 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": "^7.3|^8.0" + "php": "^8.2" }, "autoload": { "psr-4": { diff --git a/src/CoddinStubsServiceProvider.php b/src/CoddinStubsServiceProvider.php index e8f7d61..ab8c2b8 100644 --- a/src/CoddinStubsServiceProvider.php +++ b/src/CoddinStubsServiceProvider.php @@ -28,6 +28,7 @@ private function registerCommands() if ($this->app->runningInConsole()) { $this->commands([ Console\InstallCommand::class, + Console\UpdateCommand::class, ]); } } diff --git a/src/Console/UpdateCommand.php b/src/Console/UpdateCommand.php new file mode 100644 index 0000000..21acadb --- /dev/null +++ b/src/Console/UpdateCommand.php @@ -0,0 +1,23 @@ +comment('Publishing Coddin Stubs Provider...'); + $this->callSilent('vendor:publish', [ + '--tag' => 'stubs', + '--force' => true, + ]); + } +} diff --git a/stubs/console.stub b/stubs/console.stub index 341d8f2..37149df 100644 --- a/stubs/console.stub +++ b/stubs/console.stub @@ -8,16 +8,12 @@ use Illuminate\Console\Command; final class {{ class }} extends Command { - public function handle(): void - { - // Add your command logic - } + protected $signature = '{{ command }}'; - protected function configure(): void - { - $this->setName('command:name'); - $this->setDescription('Command description'); + protected $description = 'Command description'; - parent::configure(); + public function handle(): int + { + return self::SUCCESS; } } diff --git a/stubs/observer.stub b/stubs/observer.stub index d7ce70b..9185b2f 100644 --- a/stubs/observer.stub +++ b/stubs/observer.stub @@ -8,57 +8,27 @@ use {{ namespacedModel }}; final class {{ class }} { - /** - * Handle the {{ model }} "created" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void - */ - public function created({{ model }} ${{ modelVariable }}) + public function created({{ model }} ${{ modelVariable }}): void { // } - /** - * Handle the {{ model }} "updated" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void - */ - public function updated({{ model }} ${{ modelVariable }}) + public function updated({{ model }} ${{ modelVariable }}): void { // } - /** - * Handle the {{ model }} "deleted" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void - */ - public function deleted({{ model }} ${{ modelVariable }}) + public function deleted({{ model }} ${{ modelVariable }}): void { // } - /** - * Handle the {{ model }} "restored" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void - */ - public function restored({{ model }} ${{ modelVariable }}) + public function restored({{ model }} ${{ modelVariable }}): void { // } - /** - * Handle the {{ model }} "force deleted" event. - * - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return void - */ - public function forceDeleted({{ model }} ${{ modelVariable }}) + public function forceDeleted({{ model }} ${{ modelVariable }}): void { // } diff --git a/stubs/policy.stub b/stubs/policy.stub index 986398f..88a9fcf 100644 --- a/stubs/policy.stub +++ b/stubs/policy.stub @@ -12,85 +12,38 @@ final class {{ class }} { use HandlesAuthorization; - /** - * Determine whether the user can view any models. - * - * @param \{{ namespacedUserModel }} $user - * @return mixed - */ - public function viewAny({{ user }} $user) + public function viewAny({{ user }} $user): bool { - // + return false; } - /** - * Determine whether the user can view the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return mixed - */ - public function view({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function view({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { - // + return false; } - /** - * Determine whether the user can create models. - * - * @param \{{ namespacedUserModel }} $user - * @return mixed - */ - public function create({{ user }} $user) + public function create({{ user }} $user): bool { - // + return false; } - /** - * Determine whether the user can update the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return mixed - */ - public function update({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function update({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { - // + return false; } - /** - * Determine whether the user can delete the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return mixed - */ - public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { - // + return false; } - /** - * Determine whether the user can restore the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return mixed - */ - public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { - // + return false; } - /** - * Determine whether the user can permanently delete the model. - * - * @param \{{ namespacedUserModel }} $user - * @param \{{ namespacedModel }} ${{ modelVariable }} - * @return mixed - */ - public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}) + public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool { - // + return false; } }