Ejemplo n.º 1
0
 /**
  * Store a newly created Discount in storage.
  *
  * @param CreateDiscountRequest $request
  *
  * @return Response
  */
 public function store(CreateDiscountRequest $request)
 {
     $input = $request->all();
     $discount = $this->discountRepository->create($input);
     Flash::success('Discount saved successfully.');
     return redirect(route('discounts.index'));
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\CreateDiscountRequest $request
  * @param Company                        $company
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\CreateDiscountRequest $request, Company $company)
 {
     $input = $request->all();
     $input['to'] = strtotime($input['to']);
     $input['from'] = strtotime($input['from']);
     // names and paths
     $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);
     // creating discount row
     $discount = Discount::create($input);
     $discount->image = $name . '.' . $ext;
     $discount->save();
     // attach discount to company
     $company->addDiscount($discount);
     return redirect()->route('admin.company.profile', $company->id)->with('Success', 'Korting is toegevoegd.');
 }