2015-12-13 04:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Http\Requests\API\SettingRequest;
|
|
|
|
use App\Models\Setting;
|
2018-08-19 15:26:34 +00:00
|
|
|
use App\Services\MediaSyncService;
|
|
|
|
use Exception;
|
2017-06-04 01:30:45 +00:00
|
|
|
use Illuminate\Http\JsonResponse;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
class SettingController extends Controller
|
|
|
|
{
|
2018-08-19 15:26:34 +00:00
|
|
|
private $mediaSyncService;
|
|
|
|
|
|
|
|
public function __construct(MediaSyncService $mediaSyncService)
|
|
|
|
{
|
|
|
|
$this->mediaSyncService = $mediaSyncService;
|
|
|
|
}
|
|
|
|
|
2015-12-13 04:42:28 +00:00
|
|
|
/**
|
|
|
|
* Save the application settings.
|
|
|
|
*
|
|
|
|
* @param SettingRequest $request
|
|
|
|
*
|
2018-08-19 15:26:34 +00:00
|
|
|
* @throws Exception
|
2018-08-19 15:26:52 +00:00
|
|
|
*
|
|
|
|
* @return JsonResponse
|
2015-12-13 04:42:28 +00:00
|
|
|
*/
|
2016-05-30 05:50:59 +00:00
|
|
|
public function store(SettingRequest $request)
|
2015-12-13 04:42:28 +00:00
|
|
|
{
|
|
|
|
// For right now there's only one setting to be saved
|
2017-04-29 02:55:41 +00:00
|
|
|
Setting::set('media_path', rtrim(trim($request->media_path), '/'));
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
// In a next version we should opt for a "MediaPathChanged" event,
|
|
|
|
// but let's just do this async now.
|
2018-08-19 15:26:34 +00:00
|
|
|
$this->mediaSyncService->sync();
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
return response()->json();
|
|
|
|
}
|
|
|
|
}
|