2015-12-13 04:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
2022-07-29 06:47:10 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2015-12-13 04:42:28 +00:00
|
|
|
use App\Http\Requests\API\SettingRequest;
|
|
|
|
use App\Models\Setting;
|
2022-07-07 10:59:56 +00:00
|
|
|
use App\Models\User;
|
2024-01-04 21:51:32 +00:00
|
|
|
use App\Services\MediaScanner;
|
2024-01-06 11:31:50 +00:00
|
|
|
use App\Values\ScanConfiguration;
|
2024-01-04 21:51:32 +00:00
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
class SettingController extends Controller
|
|
|
|
{
|
2024-01-04 21:51:32 +00:00
|
|
|
/** @param User $user */
|
|
|
|
public function __construct(private MediaScanner $mediaSyncService, private ?Authenticatable $user)
|
2018-08-19 15:26:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-04-21 22:20:21 +00:00
|
|
|
public function update(SettingRequest $request)
|
2015-12-13 04:42:28 +00:00
|
|
|
{
|
2022-07-07 10:59:56 +00:00
|
|
|
$this->authorize('admin', User::class);
|
|
|
|
|
2017-04-29 02:55:41 +00:00
|
|
|
Setting::set('media_path', rtrim(trim($request->media_path), '/'));
|
2024-01-04 21:51:32 +00:00
|
|
|
|
2024-01-06 11:31:50 +00:00
|
|
|
$this->mediaSyncService->scan(ScanConfiguration::make(owner: $this->user, makePublic: true));
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2021-12-06 17:07:43 +00:00
|
|
|
return response()->noContent();
|
2015-12-13 04:42:28 +00:00
|
|
|
}
|
|
|
|
}
|