mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 19:12:10 +00:00
Added inern app integration
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UpdateRoomSettingsRequest;
|
||||
use App\Models\Room;
|
||||
use App\Models\User;
|
||||
use App\Services\Rooms\RoomSettingsService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class RoomSettingsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly RoomSettingsService $roomSettings,
|
||||
) {}
|
||||
|
||||
public function edit(Room $room, Request $request): Response
|
||||
{
|
||||
abort_unless($request->user()?->id === $room->owner_id, 403);
|
||||
|
||||
return Inertia::render('rooms/Settings', [
|
||||
'room' => [
|
||||
'id' => $room->id,
|
||||
'title' => $room->title,
|
||||
'join_code' => $room->join_code,
|
||||
'allow_participants_to_manage_rounds' => $room->allow_participants_to_manage_rounds,
|
||||
'is_persistent' => $room->is_persistent,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(UpdateRoomSettingsRequest $request, Room $room): RedirectResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user instanceof User, 403);
|
||||
|
||||
/** @var array{allow_participants_to_manage_rounds: bool, is_persistent: bool} $settings */
|
||||
$settings = $request->validated();
|
||||
$this->roomSettings->update($room, $user, $settings);
|
||||
|
||||
Inertia::flash('toast', [
|
||||
'type' => 'success',
|
||||
'message' => 'Die Raumeinstellungen wurden gespeichert.',
|
||||
]);
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user