public function delete($id) { $sponsor = Sponsor::findOrFail($id); $sponsor->delete(); $this->flasher->success('Sponsor Deleted!', 'That sponsor has been deleted'); return redirect('admin/sponsors'); }
/** * Update the specified resource in storage. * * @param SponsorRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(SponsorRequest $request, $id) { try { $sponsor = Sponsor::findOrFail($id); $inputs = $request->all(); if ($request->hasFile('image')) { $fileName = upload($request->file('image'), 'users', $sponsor->image); $inputs['image'] = $fileName; } $sponsor->fill($inputs)->save(); } catch (ModelNotFoundException $ex) { Flash::error('No sponsor found' . $ex); return redirect()->route('sponsors.index'); } Flash::success('Sponsor information updated successfully'); return redirect()->route('sponsors.index'); }