public function destroy($id) { $issues = Issue::where('registration_id', '=', $id)->delete(); $placements = Placement::where('registration_id', '=', $id)->delete(); $receivables = Receivable::where('registration_id', '=', $id)->get(); foreach ($receivables as $receivable) { $installments = Installment::where('receivable_id', '=', $receivable->id)->get(); foreach ($installments as $installment) { $earnings = Earning::where('earnable_type', '=', 'Installment')->where('earnable_id', '=', $installment->id)->get(); foreach ($earnings as $earning) { $earning->delete(); } $installment->delete(); } $earnings = Earning::where('earnable_type', '=', 'Receivable')->where('earnable_id', '=', $receivable->id)->delete(); $reductions = Reduction::where('receivable_id', '=', $receivable->id)->delete(); $receivable->delete(); } Registration::destroy($id); Session::flash('message', 'Sukses membatalkan Pendaftaran!, Semua Data terkait pendaftaran ini telah dihapus!'); }
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')); }