/** * Execute the job. * * @return void */ public function handle() { DB::transaction(function () { $registration = UserConference::find($this->registrationId); $currentFlight = $registration->flight; if (!isset($currentFlight)) { return; } $others = Flight::where('flightNumber', $currentFlight->flightNumber)->where('airline', $currentFlight->airline)->where('arrivalDate', $currentFlight->arrivalDate)->where('arrivalTime', $currentFlight->arrivalTime)->where('airport', $currentFlight->airport)->where('id', '<>', $currentFlight->id)->get(); foreach ($others as $otherFlight) { UserConference::where('flightID', $otherFlight->id)->update(['flightID' => $currentFlight->id]); $otherFlight->delete(); } }); }
public function removeRequest($conferenceID, $registrationID) { return DB::transaction(function () use($conferenceID, $registrationID) { $registration = UserConference::find($registrationID); if (!isset($registration)) { return response()->json(["message" => "request_removed"]); } if ($registration->conferenceID != $conferenceID) { return response()->json(["message" => "request_not_in_conference"], 404); } if (is_null($this->determineAccessType($conferenceID, $registration))) { return response()->json(["message" => "not_conference_registration_approver"], 403); } $registration->delete(); Log::info("Registration request {$registrationID} of conference {$conferenceID} removed."); return response()->json(["message" => "request_removed"]); }); }
public function testDoesNotAggregateDifferentTime() { $flight = $this->createBasicFlight(1000); $flight->arrivalTime = "12:00:00"; $flight->save(); $flightTwo = $this->createBasicFlight(1000); $flightTwo->arrivalTime = "12:00:01"; $flightTwo->save(); $conf = $this->createUserConferenceEntry($flight->id); $confTwo = $this->createUserConferenceEntry($flightTwo->id); $this->runAggregator($confTwo->id); $conf = UserConference::find($conf->id); $this->assertEquals($flight->id, $conf->flight->id, "Flight got changed: original " . $flight->id . " other " . $flightTwo->id); }