koel/app/Http/Controllers/API/SettingController.php

31 lines
817 B
PHP
Raw Normal View History

2015-12-13 12:42:28 +08:00
<?php
namespace App\Http\Controllers\API;
use App\Http\Requests\API\SettingRequest;
use App\Models\Setting;
2018-08-19 17:26:34 +02:00
use App\Services\MediaSyncService;
2020-09-14 00:04:07 +02:00
use Illuminate\Http\Response;
2015-12-13 12:42:28 +08:00
class SettingController extends Controller
{
2021-06-05 12:47:56 +02:00
private MediaSyncService $mediaSyncService;
2018-08-19 17:26:34 +02:00
public function __construct(MediaSyncService $mediaSyncService)
{
$this->mediaSyncService = $mediaSyncService;
}
2020-09-14 00:04:07 +02:00
// @TODO: This should be a PUT request
2016-05-30 13:50:59 +08:00
public function store(SettingRequest $request)
2015-12-13 12:42:28 +08:00
{
2017-04-29 10:55:41 +08:00
Setting::set('media_path', rtrim(trim($request->media_path), '/'));
2015-12-13 12:42:28 +08:00
// In a next version we should opt for a "MediaPathChanged" event,
// but let's just do this async now.
2018-08-19 17:26:34 +02:00
$this->mediaSyncService->sync();
2015-12-13 12:42:28 +08:00
2020-09-14 00:04:07 +02:00
return response()->json(null, Response::HTTP_NO_CONTENT);
2015-12-13 12:42:28 +08:00
}
}