浏览代码

Merge pull request #1114 from celaraze/2.0

增加artisan admin:update升级命令
Jiang Qinghua 4 年之前
父节点
当前提交
8f176d05f3
共有 2 个文件被更改,包括 40 次插入0 次删除
  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());
+        }
+
+    }
+}