-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMeterGeographicalInformationController.php
More file actions
72 lines (64 loc) · 2.42 KB
/
Copy pathMeterGeographicalInformationController.php
File metadata and controls
72 lines (64 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace App\Http\Controllers;
use App\Http\Resources\ApiResource;
use App\Models\Meter\Meter;
use App\Services\VillageService;
use App\Services\MeterGeographicalInformationService;
use App\Services\MeterService;
use App\Services\PersonMeterService;
use Illuminate\Http\Request;
class MeterGeographicalInformationController extends Controller {
public function __construct(
private MeterGeographicalInformationService $meterGeographicalInformationService,
private PersonMeterService $personMeterService,
private VillageService $villageService,
private MeterService $meterService,
) {}
/**
* List with geo and access rate
* A list of meters with their positions and access rate payments
* The list is not paginated.
*
* @urlParam mini_grid_id int
*
* @responseFile responses/meters/meters.geo.list.json
*/
public function index(?int $miniGridId = null): ApiResource {
$villageIds = $miniGridId ? $this->villageService->getVillageIdsByMiniGridId($miniGridId) : [];
// we can get village id only by address
if ($miniGridId === null) {
$meters = $this->meterService->getUsedMetersGeoWithAccessRatePayments();
} else {
$meters = $this->meterService->getUsedMetersGeoWithAccessRatePaymentsInVillages($villageIds);
}
return ApiResource::make($meters);
}
/**
* @group People
* Person with Meters & geo
* Person details with his/her owned meter(s) and the geo coordinates where each meter is placed
* - Meters
* - Meter coordinates
* A list of meters which belong to that given person
* The list is wether sorted or paginated
*
* @urlParam person required The ID of the person
*
* @responseFile responses/people/person.meter.list.json
*/
public function show(int $personId): ApiResource {
return ApiResource::make($this->personMeterService->getPersonMetersGeographicalInformation($personId));
}
/**
* Update
* Updates the geo coordinates of the meter.
*
* @urlParam meter int
*
* @bodyParam points string. Comma seperated latitude and longitude. Example 1,2
*/
public function update(Request $request): ApiResource {
$meters = $request->all();
return ApiResource::make($this->meterGeographicalInformationService->updateGeographicalInformation($meters));
}
}