mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 15:52:09 +00:00
fix: refactored the codebase
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Room;
|
||||
use App\Models\User;
|
||||
use App\Services\Rooms\FavoriteRoomService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FavoriteRoomController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly FavoriteRoomService $favoriteRooms,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request, Room $room): RedirectResponse
|
||||
{
|
||||
abort_if($room->trashed(), 404);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user instanceof User, 401);
|
||||
|
||||
$this->favoriteRooms->toggle($user, $room);
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user