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;
 }
예제 #2
0
 public function approveRequest($conferenceId, $userInventoryId)
 {
     if (!Entrust::can(PermissionNames::ConferenceInventoryEdit($conferenceId))) {
         return response()->json(['message' => 'inventory_list_edit_denied'], 403);
     }
     $item = UserInventory::with('inventory')->find($userInventoryId);
     if (!isset($item)) {
         return response()->json(['message' => 'request_not_found'], 404);
     }
     if ($item->inventory->conferenceID != $conferenceId) {
         return response()->json(['message' => 'request_not_found_for_conference'], 404);
     }
     $item->approved = 1;
     if ($item->save()) {
         return response()->json(['message' => 'item_approved'], 200);
     } else {
         return response()->json(['message' => 'item_could_not_be_approved'], 500);
     }
 }