Skip to content

Commit 45ea2f4

Browse files
committed
Sessions: allow users to edit and delete sessions
Currently there's no way for users to rename or delete a session. Add the needed controller methods and form. I'm not particularly happy with the design yet, something I plan to get back to later. Also.. * Align the bottom margins of headers between a few pages. * Avoid session name overflows on the index page and replace our custom css class `text-overflow` with Bootstrap's `text-truncate`. * Remove an unused method stub in `SessionController`. * While at it, set Bootstrap's `text-truncate` and Trix's `trix-content` class for elements with user content to avoid overflows https://github.com/basecamp/trix/blob/main/assets/trix/stylesheets/content.scss Resolves #1029
1 parent 9f5d912 commit 45ea2f4

40 files changed

+149
-130
lines changed

app/Http/Controllers/SessionController.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111

1212
class SessionController extends Controller
1313
{
14-
public function index()
15-
{
16-
//
17-
}
18-
1914
public function create(Request $request)
2015
{
2116
if ($request->has('module')) {
@@ -70,16 +65,33 @@ public function show(Session $session)
7065

7166
public function edit(Session $session)
7267
{
73-
//
68+
abort_if($session->user_id != Auth::id(), 404);
69+
70+
return view('session-editor', [
71+
'session' => $session,
72+
]);
7473
}
7574

7675
public function update(Request $request, Session $session)
7776
{
78-
//
77+
abort_if($session->user_id != Auth::id(), 404);
78+
79+
$validated = $request->validate([
80+
'name' => 'required|string|max:500',
81+
]);
82+
83+
$session->name = $validated['name'];
84+
$session->save();
85+
86+
return redirect()->back()->with('msg-success', 'Session updated successfully');
7987
}
8088

8189
public function destroy(Session $session)
8290
{
83-
//
91+
abort_if($session->user_id != Auth::id(), 404);
92+
93+
$session->delete();
94+
95+
return redirect()->route('index')->with('msg-success', 'Session deleted successfully');
8496
}
8597
}

public/build/assets/DeckForm-B-eU7jwm.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/build/assets/DeckForm-CHmUsYff.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)