瀏覽代碼

Merge pull request #1690 from laradocs/2.0

修改判断 laravel 版本逻辑
Jiang Qinghua 3 年之前
父節點
當前提交
e7ddeaa06b
共有 3 個文件被更改,包括 15 次插入5 次删除
  1. 5 1
      resources/views/helpers/scaffold.blade.php
  2. 1 1
      src/AdminServiceProvider.php
  3. 9 3
      tests/Feature/InstallTest.php

+ 5 - 1
resources/views/helpers/scaffold.blade.php

@@ -4,6 +4,9 @@
 
     $soft = Dcat\Admin\Widgets\Checkbox::make('soft_deletes')->inline();
     $soft->options([1 => (trans('admin.scaffold.soft_delete'))]);
+    if (old('soft_deletes') != NULL) {
+        $soft->check(1);
+    }
 
     $actionCreators = Dcat\Admin\Widgets\Checkbox::make('create[]')->inline();
     $actionCreators->options([
@@ -13,7 +16,8 @@
         'controller' => (trans('admin.scaffold.create_controller')),
         'migrate' => (trans('admin.scaffold.run_migrate')),
         'lang' => (trans('admin.scaffold.create_lang')),
-    ])->checkAll(['migrate', 'migration']);
+    ]);
+    old('create') ? $actionCreators->check(old('create')) : $actionCreators->checkAll(['migration', 'migrate']);
 @endphp
 <style>
     .select2-container .select2-selection--single {

+ 1 - 1
src/AdminServiceProvider.php

@@ -169,7 +169,7 @@ class AdminServiceProvider extends ServiceProvider
     {
         if ($this->app->runningInConsole()) {
             $this->publishes([__DIR__.'/../config' => config_path()], 'dcat-admin-config');
-            if ( substr($this->app->version(), 0, 1) >= 9 ) {
+            if (version_compare($this->app->version(), '9.0.0', '>=')) {
                 $this->publishes([__DIR__.'/../resources/lang' => base_path('lang')], 'dcat-admin-lang');
             } else {
                 $this->publishes([__DIR__.'/../resources/lang' => resource_path('lang')], 'dcat-admin-lang');

+ 9 - 3
tests/Feature/InstallTest.php

@@ -31,8 +31,14 @@ class InstallTest extends TestCase
         $this->assertFileExists(config_path('admin.php'));
         $this->assertFileExists(public_path(Admin::asset()->getRealPath('@admin')));
         $this->assertFileExists(database_path('migrations/2016_01_04_173148_create_admin_tables.php'));
-        $this->assertFileExists(resource_path('lang/en/admin.php'));
-        $this->assertFileExists(resource_path('lang/zh_CN/admin.php'));
-        $this->assertFileExists(resource_path('lang/zh_CN/global.php'));
+        if (version_compare(app()->version(), '9.0.0', '>=')) {
+            $this->assertFileExists(base_path('lang/en/admin.php'));
+            $this->assertFileExists(base_path('lang/zh_CN/admin.php'));
+            $this->assertFileExists(base_path('lang/zh_CN/global.php'));
+        } else {
+            $this->assertFileExists(resource_path('lang/en/admin.php'));
+            $this->assertFileExists(resource_path('lang/zh_CN/admin.php'));
+            $this->assertFileExists(resource_path('lang/zh_CN/global.php'));
+        }
     }
 }