update
This commit is contained in:
34
app/Http/Controllers/Api/StoryInteractionController.php
Normal file
34
app/Http/Controllers/Api/StoryInteractionController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Story;
|
||||
use App\Services\SocialService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
final class StoryInteractionController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SocialService $social) {}
|
||||
|
||||
public function like(Request $request, int $storyId): JsonResponse
|
||||
{
|
||||
$story = Story::published()->findOrFail($storyId);
|
||||
|
||||
return response()->json(
|
||||
$this->social->toggleStoryLike($request->user(), $story, $request->boolean('state', true))
|
||||
);
|
||||
}
|
||||
|
||||
public function bookmark(Request $request, int $storyId): JsonResponse
|
||||
{
|
||||
$story = Story::published()->findOrFail($storyId);
|
||||
|
||||
return response()->json(
|
||||
$this->social->toggleStoryBookmark($request->user(), $story, $request->boolean('state', true))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user