Browse Source

增加admin:update命令

celaraze 4 years ago
parent
commit
e9a65bdee2
2 changed files with 40 additions and 0 deletions
  1. 1 0
      src/AdminServiceProvider.php
  2. 39 0
      src/Console/UpdateCommand.php

+ 1 - 0
src/AdminServiceProvider.php

@@ -46,6 +46,7 @@ class AdminServiceProvider extends ServiceProvider
         Console\ExtensionEnableCommand::class,
         Console\ExtensionDiableCommand::class,
         Console\ExtensionUpdateCommand::class,
+        Console\UpdateCommand::class,
     ];
 
     /**

+ 39 - 0
src/Console/UpdateCommand.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace Dcat\Admin\Console;
+
+use Illuminate\Console\Command;
+
+class UpdateCommand extends Command
+{
+    /**
+     * The console command name.
+     *
+     * @var string
+     */
+    protected $signature = 'admin:update';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Update the admin package';
+
+    /**
+     * Execute the console command.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        try {
+            $this->call('admin:publish', ['--assets --migrations --force']);
+            $this->call('migrate');
+            $this->info('DcatAdmin has updated successfully!');
+        } catch (\Exception $exception) {
+            $this->error('Woops! Updating has failed: ' . $exception->getMessage());
+        }
+
+    }
+}