Ejemplo n.º 1
0
 public function destroy($id)
 {
     $movement = Movement::find($id);
     $issue_id = $movement->issue_id;
     $base_id = $movement->base_id;
     $destination_id = $movement->destination_id;
     // restore the placement
     $placement = Placement::where('issue_id', '=', $issue_id)->where('course_id', '=', $destination_id)->first();
     if ($placement) {
         $placement->course_id = $base_id;
         $placement->save();
     }
     // deleting earning
     $earning = Earning::where('earnable_type', '=', 'Movement')->where('earnable_id', '=', $id)->first();
     if ($earning) {
         $earning->delete();
     }
     Movement::destroy($id);
     // Store to Timelines
 }