Return the battery object in endpoint /batteries (closes #2045)

This commit is contained in:
Bernd Bestel 2022-11-19 19:33:50 +01:00
parent eb370dad1e
commit 7d4a9602ab
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,55 @@
> ⚠️ xxxBREAKING CHANGESxxx
> ❗ xxxImportant upgrade informationXXX
### New feature: xxxx
- xxx
### Stock
- xxx
### Shopping list
- xxx
### Recipes
- xxx
### Meal plan
- xxx
### Chores
- xxx
### Calendar
- xxx
### Tasks
- xxx
### Batteries
- xxx
### Equipment
- xxx
### Userfields
- xxx
### General
- xxx
### API
- The Endpoint `/batteries` now also returns the corresponding battery object (as field/property `battery`)

View File

@ -26,7 +26,14 @@ class BatteriesService extends BaseService
public function GetCurrent()
{
return $this->getDatabase()->batteries_current();
$batteries = $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
$currentBatteries = $this->getDatabase()->batteries_current();
foreach ($currentBatteries as $currentBattery)
{
$currentBattery->battery = FindObjectInArrayByPropertyValue($batteries, 'id', $currentBattery->battery_id);
}
return $currentBatteries;
}
public function TrackChargeCycle(int $batteryId, string $trackedTime)