示例#1
0
 public function index()
 {
     $title = 'Kortingen';
     $now = strtotime('now');
     $discounts = Discount::where('from', '<=', $now)->where('to', '>=', $now)->paginate(20);
     return view('user.discounts.index', compact('title', 'discounts'));
 }
示例#2
0
 /**
  * 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');
 }
示例#3
0
 public function search($input)
 {
     $query = Discount::query();
     $columns = Schema::getColumnListing('discounts');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }