Chirp::with("user")->latest()->get() ]); } /** * Show the form for creating a new resource. */ public function create() { // } /** * Store a newly created resource in storage. */ public function store(Request $request) { $validated = $request->validate([ "message" => "required|string|max:255" ]); $request->user()->chirps()->create($validated); return redirect(route("chirps.index")); } /** * Display the specified resource. */ public function show(Chirp $chirp) { // } /** * Show the form for editing the specified resource. */ public function edit(Chirp $chirp) { $this->authorize("update", $chirp); return view("chirps.edit", [ "chirp" => $chirp ]); } /** * Update the specified resource in storage. */ public function update(Request $request, Chirp $chirp) { $this->authorize("update", $chirp); $validated = $request->validate([ "message" => "required|string|max:255" ]); $chirp->update($validated); return redirect(route("chirps.index")); } /** * Remove the specified resource from storage. */ public function destroy(Chirp $chirp) { $this->authorize("delete", $chirp); $chirp->delete(); return redirect(route("chirps.index")); } }