Day 7: Completing the CRUD Cycle
Summary Today’s Definition of Done: Shoot owner can edit description and color Shoot owner can destroy a shoot after confirmation Edit and Delete controls visible from dashboard Work Session The first thing I did for Day 7 is start working on the SiteController to add the edit and update methods. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 public function edit(Site $site) { if ($site->user_id !== auth()->id()) { abort(403); } return view('sites.edit', compact('site')); } public function update(Request $request, Site $site) { if ($site->user_id !== auth()->id()) { abort(403); } $validated = $request->validate([ 'name' => 'required|string|max:255', 'description' => 'nullable|string|max:1000', 'theme_color' => 'required|string|in:blue,green,purple', ]); $site->update($validated); return redirect()->route('dashboard')->with('success', 'Shoot updated successfully!'); } Then I added the destroy method just to get everything in place in the controller. ...