koel/app/Http/Controllers/API/SettingController.php
2018-08-19 17:26:52 +02:00

40 lines
973 B
PHP

<?php
namespace App\Http\Controllers\API;
use App\Http\Requests\API\SettingRequest;
use App\Models\Setting;
use App\Services\MediaSyncService;
use Exception;
use Illuminate\Http\JsonResponse;
class SettingController extends Controller
{
private $mediaSyncService;
public function __construct(MediaSyncService $mediaSyncService)
{
$this->mediaSyncService = $mediaSyncService;
}
/**
* Save the application settings.
*
* @param SettingRequest $request
*
* @throws Exception
*
* @return JsonResponse
*/
public function store(SettingRequest $request)
{
// For right now there's only one setting to be saved
Setting::set('media_path', rtrim(trim($request->media_path), '/'));
// In a next version we should opt for a "MediaPathChanged" event,
// but let's just do this async now.
$this->mediaSyncService->sync();
return response()->json();
}
}