Implement creator studio and upload updates
This commit is contained in:
55
app/Http/Controllers/Studio/StudioCommentsApiController.php
Normal file
55
app/Http/Controllers/Studio/StudioCommentsApiController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Studio;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Studio\CreatorStudioCommentService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
final class StudioCommentsApiController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CreatorStudioCommentService $comments,
|
||||
) {
|
||||
}
|
||||
|
||||
public function reply(Request $request, string $module, int $commentId): JsonResponse
|
||||
{
|
||||
$payload = $request->validate([
|
||||
'content' => ['required', 'string', 'min:1', 'max:10000'],
|
||||
]);
|
||||
|
||||
$this->comments->reply($request->user(), $module, $commentId, (string) $payload['content']);
|
||||
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
|
||||
public function moderate(Request $request, string $module, int $commentId): JsonResponse
|
||||
{
|
||||
$this->comments->moderate($request->user(), $module, $commentId);
|
||||
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
|
||||
public function report(Request $request, string $module, int $commentId): JsonResponse
|
||||
{
|
||||
$payload = $request->validate([
|
||||
'reason' => ['required', 'string', 'max:120'],
|
||||
'details' => ['nullable', 'string', 'max:4000'],
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'report' => $this->comments->report(
|
||||
$request->user(),
|
||||
$module,
|
||||
$commentId,
|
||||
(string) $payload['reason'],
|
||||
isset($payload['details']) ? (string) $payload['details'] : null,
|
||||
),
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user