public function update($id) { $promotion = Promotion::find($id); $promotion->project_id = Auth::user()->curr_project_id; $promotion->name = Input::get('name'); $promotion->description = Input::get('description'); $promotion->discount = Input::get('discount'); $promotion->nominal = Input::get('nominal'); $promotion->last_valid = Input::get('last_valid'); $promotion->save(); Session::flash('message', 'Sukses mengupdate promo'); }
public function reductionsFilter($types, $id) { $reductable_type = $types; $reduction_id = $id; $reductions = Reduction::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('reductable_type', '=', $reductable_type)->where('reductable_id', '=', $reduction_id)->get(); switch ($reductable_type) { case 'Promotion': $discounts = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get(); $discount = Promotion::find($reduction_id); break; case 'Voucher': $discounts = Voucher::where('project_id', '=', Auth::user()->curr_project_id)->get(); $discount = Voucher::find($reduction_id); break; case 'Discount': $discounts = Discount::all(); $discount = Discount::find($reduction_id); break; case 'Charge': $discounts = Charge::where('project_id', '=', Auth::user()->curr_project_id)->get(); $discount = Charge::find($reduction_id); break; default: $discounts = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get(); $discount = Promtion::find($reduction_id); break; } $menu = 'report'; return View::make('reports.reductions', compact('reductable_type', 'reduction_id', 'reductions', 'discounts', 'discount', 'menu')); }