validate([ 'title' => 'required|max:255', 'url' => 'required', ]); Item::create($request->all()); return redirect()->route('items.index') ->with('success','Item created successfully'); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // Get the item $item = Item::find($id); // show the edit form and pass the nerd return view('items.edit') ->with('item', $item); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $validatedData = $request->validate([ 'title' => 'required|max:255', 'url' => 'required', ]); Item::find($id)->update($request->all()); return redirect()->route('items.index') ->with('success','Item updated successfully'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // Item::find($id)->delete(); return redirect()->route('items.index') ->with('success','Item deleted successfully'); } }