Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.0' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jqhph committed Nov 16, 2020
2 parents cf64756 + 9b99a8a commit f219ccb
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
3 changes: 3 additions & 0 deletions config/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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();
Expand All @@ -32,6 +37,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('admin_settings');
Schema::dropIfExists($this->config('database.settings_table'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@

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.
*
* @return void
*/
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('');
Expand All @@ -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);
Expand All @@ -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'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

class Extension extends Model
{
protected $table = 'admin_extensions';

protected $fillable = ['name', 'is_enabled', 'version', 'options'];

protected $casts = [
Expand All @@ -20,6 +18,8 @@ public function __construct(array $attributes = [])

$this->setConnection($connection);

$this->setTable(config('admin.database.extensions_table'));

parent::__construct($attributes);
}
}
4 changes: 2 additions & 2 deletions src/Models/ExtensionHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

class ExtensionHistory extends Model
{
protected $table = 'admin_extension_histories';

protected $fillable = ['name', 'type', 'version', 'detail'];

public function __construct(array $attributes = [])
Expand All @@ -16,6 +14,8 @@ public function __construct(array $attributes = [])

$this->setConnection($connection);

$this->setTable(config('admin.database.extension_histories_table'));

parent::__construct($attributes);
}
}
3 changes: 2 additions & 1 deletion src/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class Setting extends Model
{
protected $table = 'admin_settings';
protected $primaryKey = 'slug';
public $incrementing = false;
protected $fillable = ['slug', 'value'];
Expand All @@ -17,6 +16,8 @@ public function __construct(array $attributes = [])

$this->setConnection($connection);

$this->setTable(config('admin.database.settings_table'));

parent::__construct($attributes);
}
}

0 comments on commit f219ccb

Please sign in to comment.