add all controllers logic
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Ui;
|
||||
|
||||
use App\Http\Controllers\Api\BaseApiController;
|
||||
use App\Http\Requests\Ui\UiStyleRequest;
|
||||
use App\Http\Resources\Ui\UiStyleResource;
|
||||
use App\Services\Ui\UiStyleService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class UiController extends BaseApiController
|
||||
{
|
||||
public function __construct(private UiStyleService $styleService)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function style(UiStyleRequest $request): JsonResponse
|
||||
{
|
||||
$userId = (int) (auth()->id() ?? 0);
|
||||
if ($userId <= 0) {
|
||||
return $this->error('Unauthorized.', Response::HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
$prefs = $this->styleService->update($userId, $request->validated());
|
||||
|
||||
return $this->success([
|
||||
'preferences' => new UiStyleResource($prefs),
|
||||
], 'Style updated.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user