/**
  * 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 static function getAccountRegistrationData($conferenceId, $account = null)
 {
     if (is_null($account)) {
         $account = Auth::user();
     }
     //If no user is logged in, return an empty list
     if (is_null($account)) {
         return [];
     }
     $accountId = $account->id;
     $attendances = UserConference::where("conferenceID", $conferenceId)->whereHas("user", function ($query) use($accountId) {
         $query->where("accountID", $accountId);
     })->get();
     $attendees = [];
     foreach ($attendances as $a) {
         $attendanceInventory = UserInventory::with('inventory')->whereHas('inventory', function ($query) use($conferenceId) {
             $query->where('conferenceID', $conferenceId);
         })->where('userID', $a->userID)->get()->toArray();
         $attendees[] = ["user" => $a->userID, "userData" => $a->user, "status" => $a->approved ? "approved" : "pending", "id" => $a->id, "flight" => $a->flight, "room" => $a->room()->with('roomSet.residence', 'roomSet.type')->get()->toArray(), "userTransportation" => $a->userTransportation()->with('transportation')->get()->toArray(), "userInventory" => $attendanceInventory];
     }
     return $attendees;
 }
Exemplo n.º 3
0
 /**
  * Replaces a given conference with the new values, given valid json.
  */
 public function replace(Request $req, $id)
 {
     if (!Entrust::can(PermissionNames::ConferenceInfoEdit($id))) {
         return response("", 403);
     }
     $this->validateConferenceJson($req);
     $conf = Conference::find($id);
     if (is_null($conf)) {
         return response("Conference {$id} does not exist.", 400);
     }
     $this->assignInputToConference($req, $conf);
     $conf->save();
     Log::info("Conference info for " . $conf->conferenceName . " edited.");
     $recipientModels = UserConference::where('conferenceID', $id)->with('user.account')->get();
     $recipients = [];
     foreach ($recipientModels as $model) {
         if ($model->user->account->receiveUpdates) {
             $recipients[] = $model->user->account->email;
         } else {
             Log::debug("Discarding {$model->user->account->email} as updates aren't enabled");
         }
     }
     Log::info("Dispatching conference update for " . sizeof($recipients) . " recipients");
     $this->dispatch(new SendUpdateEmail("Conference Updated", "update-notification", ['typestr' => 'conference', 'name' => $conf->conferenceName, 'link' => config('app.url') . '/dashboard/conferences/list'], $recipients));
     return '';
 }
 public function missingAssignments($confId)
 {
     if (!Entrust::can(PermissionNames::ConferenceRoomEdit($confId))) {
         return response("", 403);
     }
     return UserConference::where("needsAccommodation", true)->has("room", "<", 1)->where('conferenceID', $confId)->with("user")->get();
 }
Exemplo n.º 5
0
 public function outstandingRegistrationRequests(Request $req, $conferenceID)
 {
     if (!$this->isUserRegistrationApprover($conferenceID)) {
         return response("", 403);
     }
     $this->validateRegistrationListingRequest($req);
     if ($req->has("include")) {
         $include = $req->input("include");
     } else {
         $include = "all";
     }
     $query = UserConference::with("user", "flight")->where("conferenceID", $conferenceID);
     if ($include === "pending") {
         $query->where("approved", false);
     } else {
         if ($include === "approved") {
             $query->where("approved", true);
         }
     }
     Log::info("Building final registration request list data");
     return array_map(function ($uc) {
         $uc['hasFlight'] = isset($uc['flightID']);
         return $uc;
     }, $query->get()->toArray());
 }
Exemplo n.º 6
0
 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);
 }
 public function transportSummary($confId, Request $req)
 {
     if (!Entrust::can(PermissionNames::ConferenceTransportationEdit($confId))) {
         return response()->json(['message' => 'cannot_manage_transport'], 403);
     }
     if (!$this->isValidConference($confId)) {
         return response()->json(['message' => 'conference_not_found'], 404);
     }
     $userConfs = UserConference::where('needsTransportation', '=', true)->where('conferenceID', $confId)->where('approved', 1)->with(array('user' => function ($q) {
         $q->select('id', 'firstName', 'lastName', 'accountID');
     }))->with('userTransportation');
     $transports = [];
     foreach ($userConfs->get() as &$userConf) {
         $ut = $userConf->userTransportation;
         if ($ut != null) {
             $transport = Transportation::where('id', $ut->transportationID)->first();
             $transports[$transport->id] = $transport;
         }
     }
     $flightsList = $userConfs->distinct()->lists('flightID');
     $flights = Flight::whereIn('id', $flightsList)->get()->keyBy('id')->toArray();
     $conference = Conference::where('id', $confId)->get()->toArray();
     $summary = $this->buildSummaryJson($conference, $flights, $userConfs->get()->toArray(), $transports);
     return response()->json($summary, 200);
 }