Skip to content

Commit

Permalink
Allow the database connection and table name to be configured
Browse files Browse the repository at this point in the history
  • Loading branch information
emielmolenaar authored and ctf0 committed Nov 2, 2019
1 parent c587f07 commit 9850bbb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct()
$this->storageDisk = app('filesystem')->disk($this->fileSystem);
$this->storageDiskInfo = app('config')->get("filesystems.disks.{$this->fileSystem}");
$this->baseUrl = $this->storageDisk->url('/');
$this->db = app('db')->connection('mediamanager')->table('locked');
$this->db = app('db')->connection($config['database_connection'] ?? 'mediamanager')->table($config['table_locked'] ?? 'locked');

$this->storageDisk->addPlugin(new ListWith());
}
Expand Down
10 changes: 10 additions & 0 deletions src/config/mediaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,14 @@
* preview and remove files b4 uploading
*/
'preview_files_before_upload' => true,

/*
* Database connection (defaults to "mediamanager")
*/
'database_connection' => 'mediamanager',

/*
* Locked items table name (defaults to "locked")
*/
'table_locked' => 'locked'
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@

class CreateMediaManagerLockListTable extends Migration
{
protected $tableName;

public function __construct()
{
$this->tableName = config('mediaManager.table_locked', 'locked');
}

/**
* Run the migrations.
*/
public function up()
{
Schema::create('locked', function (Blueprint $table) {
Schema::create($this->tableName, function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('path');
});
Expand All @@ -22,6 +29,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('locked');
Schema::dropIfExists($this->tableName);
}
}

0 comments on commit 9850bbb

Please sign in to comment.