/**
  * Update the specified resource in storage.
  *
  * @param Requests\UpdateDiscountRequest $request
  * @param Company                        $company
  * @param Discount                       $discount
  *
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\UpdateDiscountRequest $request, Company $company, Discount $discount)
 {
     $input = $request->all();
     $input['to'] = strtotime($input['to']);
     $input['from'] = strtotime($input['from']);
     // Updating discount
     $discount->update($input);
     if (!empty($request->file('file'))) {
         $name = uniqid(strtotime('now'));
         $ext = $request->file('file')->getClientOriginalExtension();
         $file = $request->file('file');
         $path = public_path('uploads/discounts/' . $name . '.' . $ext);
         // uploading image
         $img = Image::make($file)->save($path);
         $discount->image = $name . '.' . $ext;
         $discount->save();
     }
     return redirect()->route('admin.company.profile', $company->id)->with('Success', 'Korting bijgewerkt');
 }
Exemple #2
0
 /**
  * Update the specified Discount in storage.
  *
  * @param  int              $id
  * @param UpdateDiscountRequest $request
  *
  * @return Response
  */
 public function update($id, UpdateDiscountRequest $request)
 {
     $discount = $this->discountRepository->find($id);
     if (empty($discount)) {
         Flash::error('Discount not found');
         return redirect(route('discounts.index'));
     }
     $this->discountRepository->updateRich($request->all(), $id);
     Flash::success('Discount updated successfully.');
     return redirect(route('discounts.index'));
 }