Including a findOrFail to Edit ITEM

This commit is contained in:
Bruno F. Fontes 2018-09-16 20:31:27 -03:00
parent 4b9ac0c133
commit 92f901e3a5

View File

@ -49,7 +49,7 @@ class ItemController extends Controller
public function patch(Request $request) public function patch(Request $request)
{ {
$request->validate(['item' => 'required', 'name' => 'required']); $request->validate(['item' => 'required', 'name' => 'required']);
$item = User::find(\Auth::id())->items()->find(request('item')); $item = User::findOrFail(\Auth::id())->items()->find(request('item'));
$item->name = request('name'); $item->name = request('name');
$item->save(); $item->save();
return redirect('item/'.request('item')); return redirect('item/'.request('item'));