mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-24 04:14:57 +00:00
Including a findOrFail to Edit ITEM
This commit is contained in:
parent
4b9ac0c133
commit
92f901e3a5
@ -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'));
|
||||||
|
Loading…
Reference in New Issue
Block a user