public function edit(Voucher $voucher) { $this->voucher = $voucher; $rules = array('title' => 'required|max:100', 'img' => 'image|mimes:jpeg,jpg,svg,png,gif', 'starts_at' => 'date_format:"Y-m-d"|required', 'finishes_at' => 'required|date_format:"Y-m-d"'); $validator = Validator::make(Input::all(), $rules); if (!$validator->fails()) { $file = Input::file('img'); $voucher->update(Input::except('img')); if (Input::hasFile('img')) { $voucher->img = $this->uploadImage($file); } $this->setCheckboxesAndMailingState(); $voucher->save(); return Redirect::to('admin/vouchers')->with('success', 'Voucher updated successfully!'); } return Redirect::back()->withInput()->withErrors($validator); }