/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $amounts = $request->input('amount'); $ids = $request->input('itemIds'); //dd($request); $flag = "whoops"; foreach ($amounts as $key => $amount) { if (is_numeric($amount)) { $flag = 'good'; $val = number_format($amount * 100, 0, '', ''); $item = Item::findorFail($ids[$key]); $item->price = $val; $item->save(); } } if ($flag == "whoops") { return redirect()->route('recent')->with('imessage', 'You did not enter any prices!'); } return redirect()->route('recent')->with('gmessage', 'Your prices have been saved!'); }