diff --git a/config/admin.php b/config/admin.php index e3178717f..31102874d 100755 --- a/config/admin.php +++ b/config/admin.php @@ -264,6 +264,9 @@ 'role_permissions_table' => 'admin_role_permissions', 'role_menu_table' => 'admin_role_menu', 'permission_menu_table' => 'admin_permission_menu', + 'settings_table' => 'admin_settings', + 'extensions_table' => 'admin_extensions', + 'extension_histories_table' => 'admin_extension_histories', ], /* diff --git a/database/migrations/2016_01_04_173148_create_admin_tables.php b/database/migrations/2016_01_04_173148_create_admin_tables.php index 3dcb1fe9d..0877845a1 100755 --- a/database/migrations/2016_01_04_173148_create_admin_tables.php +++ b/database/migrations/2016_01_04_173148_create_admin_tables.php @@ -8,7 +8,7 @@ class CreateAdminTables extends Migration { public function getConnection() { - return config('database.connection') ?: config('database.default'); + return $this->config('database.connection') ?: config('database.default'); } public function config($key) diff --git a/database/migrations/2020_09_07_090635_create_admin_settings_table.php b/database/migrations/2020_09_07_090635_create_admin_settings_table.php index 89aeac4a2..2c5d7f854 100644 --- a/database/migrations/2020_09_07_090635_create_admin_settings_table.php +++ b/database/migrations/2020_09_07_090635_create_admin_settings_table.php @@ -8,7 +8,12 @@ class CreateAdminSettingsTable extends Migration { public function getConnection() { - return config('database.connection') ?: config('database.default'); + return $this->config('database.connection') ?: config('database.default'); + } + + public function config($key) + { + return config('admin.'.$key); } /** @@ -18,7 +23,7 @@ public function getConnection() */ public function up() { - Schema::create('admin_settings', function (Blueprint $table) { + Schema::create($this->config('database.settings_table'), function (Blueprint $table) { $table->string('slug', 100)->primary(); $table->longText('value'); $table->timestamps(); @@ -32,6 +37,6 @@ public function up() */ public function down() { - Schema::dropIfExists('admin_settings'); + Schema::dropIfExists($this->config('database.settings_table')); } } diff --git a/database/migrations/2020_09_22_015815_create_admin_extensions_table.php b/database/migrations/2020_09_22_015815_create_admin_extensions_table.php index addb39eee..2320010f9 100644 --- a/database/migrations/2020_09_22_015815_create_admin_extensions_table.php +++ b/database/migrations/2020_09_22_015815_create_admin_extensions_table.php @@ -6,6 +6,16 @@ class CreateAdminExtensionsTable extends Migration { + public function getConnection() + { + return $this->config('database.connection') ?: config('database.default'); + } + + public function config($key) + { + return config('admin.'.$key); + } + /** * Run the migrations. * @@ -13,7 +23,7 @@ class CreateAdminExtensionsTable extends Migration */ public function up() { - Schema::create('admin_extensions', function (Blueprint $table) { + Schema::create($this->config('database.extensions_table'), function (Blueprint $table) { $table->increments('id')->unsigned(); $table->string('name', 100)->unique(); $table->string('version', 20)->default(''); @@ -24,7 +34,7 @@ public function up() $table->engine = 'InnoDB'; }); - Schema::create('admin_extension_histories', function (Blueprint $table) { + Schema::create($this->config('database.extension_histories_table'), function (Blueprint $table) { $table->bigIncrements('id')->unsigned(); $table->string('name', 100); $table->tinyInteger('type')->default(1); @@ -45,7 +55,7 @@ public function up() */ public function down() { - Schema::dropIfExists('admin_extensions'); - Schema::dropIfExists('admin_extension_histories'); + Schema::dropIfExists($this->config('database.extensions_table')); + Schema::dropIfExists($this->config('database.extension_histories_table')); } } diff --git a/database/migrations/2020_11_01_083237_update_admin_menu_table.php b/database/migrations/2020_11_01_083237_update_admin_menu_table.php index 5b9609390..56d7f6d1e 100644 --- a/database/migrations/2020_11_01_083237_update_admin_menu_table.php +++ b/database/migrations/2020_11_01_083237_update_admin_menu_table.php @@ -8,7 +8,7 @@ class UpdateAdminMenuTable extends Migration { public function getConnection() { - return config('database.connection') ?: config('database.default'); + return $this->config('database.connection') ?: config('database.default'); } public function config($key) diff --git a/src/Models/Extension.php b/src/Models/Extension.php index a5b5ce0cc..46253170c 100644 --- a/src/Models/Extension.php +++ b/src/Models/Extension.php @@ -6,8 +6,6 @@ class Extension extends Model { - protected $table = 'admin_extensions'; - protected $fillable = ['name', 'is_enabled', 'version', 'options']; protected $casts = [ @@ -20,6 +18,8 @@ public function __construct(array $attributes = []) $this->setConnection($connection); + $this->setTable(config('admin.database.extensions_table')); + parent::__construct($attributes); } } diff --git a/src/Models/ExtensionHistory.php b/src/Models/ExtensionHistory.php index 276d57334..c0ab0841d 100644 --- a/src/Models/ExtensionHistory.php +++ b/src/Models/ExtensionHistory.php @@ -6,8 +6,6 @@ class ExtensionHistory extends Model { - protected $table = 'admin_extension_histories'; - protected $fillable = ['name', 'type', 'version', 'detail']; public function __construct(array $attributes = []) @@ -16,6 +14,8 @@ public function __construct(array $attributes = []) $this->setConnection($connection); + $this->setTable(config('admin.database.extension_histories_table')); + parent::__construct($attributes); } } diff --git a/src/Models/Setting.php b/src/Models/Setting.php index 35e7906ca..53253cee5 100644 --- a/src/Models/Setting.php +++ b/src/Models/Setting.php @@ -6,7 +6,6 @@ class Setting extends Model { - protected $table = 'admin_settings'; protected $primaryKey = 'slug'; public $incrementing = false; protected $fillable = ['slug', 'value']; @@ -17,6 +16,8 @@ public function __construct(array $attributes = []) $this->setConnection($connection); + $this->setTable(config('admin.database.settings_table')); + parent::__construct($attributes); } }