/** * Verify if exist */ private function dataExist($id) { $data = Charge::find($id); if (!$data) { return Redirect::route('charge_list', 'all')->with('mError', 'Cette charge est introuvable !'); } else { return $data; } }
public function update($id) { $nominal = Input::get('nominal'); $nominal = str_replace(",", ".", $nominal); $nominal = str_replace(".", "", $nominal); $nominal = substr($nominal, 0, -2); $charge = Charge::find($id); $charge->name = Input::get('name'); $charge->nominal = $nominal; $charge->description = Input::get('description'); $charge->save(); Session::flash('message', 'Sukses mengupdate Charge!'); }
/** * Show the form for editing the specified charge. * * @param int $id * @return Response */ public function edit($id) { $charge = Charge::find($id); return View::make('charges.edit', compact('charge')); }
/** * Remove the specified resource from storage. * DELETE /chares/{id} * * @param int $id * @return Response */ public function destroy($id) { Charge::find($id)->delete(); return Redirect::route('charge'); }
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')); }