2024-02-25 09:11:15 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands\Storage;
|
|
|
|
|
|
|
|
|
|
use App\Facades\License;
|
|
|
|
|
use App\Models\Setting;
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
class StorageCommand extends Command
|
|
|
|
|
{
|
|
|
|
|
protected $signature = 'koel:storage';
|
2024-03-09 12:20:36 +00:00
|
|
|
|
protected $description = 'Set up and configure Koel’s storage';
|
2024-02-25 09:11:15 +00:00
|
|
|
|
|
|
|
|
|
public function handle(): int
|
|
|
|
|
{
|
|
|
|
|
$this->info('This command will set up and configure Koel’s storage.');
|
|
|
|
|
|
|
|
|
|
$this->info('Current storage configuration:');
|
|
|
|
|
$this->components->twoColumnDetail('Driver', config('koel.storage_driver'));
|
|
|
|
|
|
|
|
|
|
if (config('koel.storage_driver') === 'local') {
|
|
|
|
|
$this->components->twoColumnDetail('Media path', Setting::get('media_path') ?: '<not set>');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (License::isPlus()) {
|
2024-07-03 19:40:39 +00:00
|
|
|
|
$choices = [
|
|
|
|
|
'local' => 'This server',
|
|
|
|
|
's3' => 'Amazon S3 or compatible services (DO Spaces, Cloudflare R2, etc.)',
|
|
|
|
|
'dropbox' => 'Dropbox',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$driver = $this->choice(
|
|
|
|
|
'Where do you want to store your media files?',
|
|
|
|
|
$choices,
|
|
|
|
|
config('koel.storage_driver')
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$driver = 'local';
|
2024-02-25 09:11:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-03 19:40:39 +00:00
|
|
|
|
if ($this->call("koel:storage:$driver") === self::SUCCESS) {
|
2024-02-25 09:11:15 +00:00
|
|
|
|
$this->output->success('Storage has been set up.');
|
|
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self::FAILURE;
|
|
|
|
|
}
|
|
|
|
|
}
|