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 normalizeIssue() { $issues = Issue::all(); foreach ($issues as $issue) { // Normalize Educations $educations = Education::where('student_id', '=', $issue->student_id)->get(); foreach ($educations as $education) { $education->student_id = $issue->id; $education->save(); } // Normalize Placements $placements = Placement::where('student_id', '=', $issue->student_id)->get(); foreach ($placements as $placement) { $placement->student_id = $issue->id; $placement->save(); } // Normalize Receivables $receivables = Receivable::where('student_id', '=', $issue->student_id)->get(); foreach ($receivables as $receivable) { $receivable->student_id = $issue->id; $receivable->save(); } } }
/** * Show the form for editing the specified resource. * GET /properties/{id}/edit * * @param int $id * @return Response */ public function edit($id) { $properties = Property::find($id); $owners = Owner::where('agent_id', '=', Sentry::getUser()->id)->get(); $deposits = Receivable::where('receivable_type', '=', 'deposit')->get(); $others = Receivable::where('receivable_type', '=', 'recurrent')->get(); if (is_null($properties)) { return Redirect::route('admin.property.index'); } return View::make('backend.code.property.edit', compact('properties', 'owners', 'deposits', 'others')); }
public function update($id) { $movement_costs = Input::get('movement_costs'); $movement_costs = str_replace(",", ".", $movement_costs); $movement_costs = str_replace(".", "", $movement_costs); $movement_costs = substr($movement_costs, 0, -2); $upgrade_costs = Input::get('upgrade_costs'); $upgrade_costs = str_replace(",", ".", $upgrade_costs); $upgrade_costs = str_replace(".", "", $upgrade_costs); $upgrade_costs = substr($upgrade_costs, 0, -2); $movement = Movement::findOrFail($id); $last_course_id = $movement->destination_id; $student_id = $movement->student_id; $movement->destination_id = Input::get('destination_id'); $movement->employee_id = Input::get('employee_id'); $movement->movement_date = Input::get('date'); $movement->movement_costs = $movement_costs; $movement->upgrade_costs = $upgrade_costs; $movement->comments = Input::get('comments'); $movement->save(); if ((double) $upgrade_costs > 0) { $receivable = Receivable::where('registration_id', '=', $placement->registration_id)->first(); $receivable->total = $receivable->total + $upgrade_costs; $receivable->receivable = $receivable->receivable + $upgrade_costs; $receivable->balance = $receivable->balance + $upgrade_costs; $receivable->save(); } $earning_count = Earning::where('earnable_type', '=', 'Movement')->where('earnable_id', '=', $id)->count(); if ($earning_count > 0) { $earning = Earning::where('earnable_type', '=', 'Movement')->where('earnable_id', '=', $id)->first(); $earning->payment = $movement_costs + $upgrade_costs; $earning->save(); } }