I have an api query done in php (Laravel) from a Wild Apricot member management system and it is returning an array of events that has the following structure (see below). I would like to sort the array by StartDate in ascending order to prep the array display that is done and passed to the Laravel selector widget. Wondering what the best approach to do this would be... any ideas and/or thoughts would be welcomed! Will chug along and test, but thought I would post that up here regardless. ;-P
{
"Events": [
{
"Id": 4077234,
"Url": "https://api.wildapricot.org/v2.2/accounts/ACCOUNTID/Events/4077234",
"EventType": "Regular",
"StartDate": "2021-12-03T19:00:00+11:00",
"EndDate": "2021-12-05T15:30:00+11:00",
"Location": "LOCATION1",
"RegistrationEnabled": true,
"RegistrationsLimit": 1,
"PendingRegistrationsCount": 0,
"ConfirmedRegistrationsCount": 1,
"CheckedInAttendeesNumber": 0,
"Tags": [],
"AccessLevel": "Restricted",
"StartTimeSpecified": true,
"EndTimeSpecified": true,
"HasEnabledRegistrationTypes": true,
"Name": "NAME1"
},
{
"Id": 4334234,
"Url": "https://api.wildapricot.org/v2.2/accounts/ACCOUNTID/Events/4334234",
"EventType": "Regular",
"StartDate": "2021-11-27T00:00:00+11:00",
"EndDate": "2021-11-28T00:00:00+11:00",
"Location": "LOCATION2",
"RegistrationEnabled": true,
"RegistrationsLimit": 50,
"PendingRegistrationsCount": 0,
"ConfirmedRegistrationsCount": 9,
"CheckedInAttendeesNumber": 0,
"Tags": [],
"AccessLevel": "Restricted",
"StartTimeSpecified": false,
"EndTimeSpecified": false,
"HasEnabledRegistrationTypes": true,
"Name": "NAME2"
},
}
Here's the query that is being done..
$queryParams3 = array(
'$async' => 'false',
// We want the list of events
// https://api.wildapricot.org/v2.2/accounts/ACCOUNTID/Events?$filter=(StartDate gt 2021-05-01)
'$filter' => "(StartDate gt 2021-05-01)"
);
$url3 = $accountUrl . '/Events/?' . http_build_query($queryParams3);
$eventsResult = $waApiClient->makeRequest($url3); // json is returned > have been done a json_decode on it..
$events = $eventsResult['Events'];
Reason of wanting to do this is that it just makes it simpler for the user to read the events listed in events that are current (e.g. closest to today's date) vs events that are further out.. as background info, this is for a small sms portal that I am building out. ;-P