Add latitude and longitude properties to departments
- Introduced `latitude` and `longitude` properties in `departments_o` for geographic data support. - Updated department routes to handle latitude/longitude in responses and parameter updates. - Adjusted serialization and object creation to include new properties.
This commit is contained in:
@@ -20,6 +20,8 @@ class departments_o extends db
|
||||
public object_property $dimension; // The dimension of the department
|
||||
public object_property $visible; // The visibility of the department
|
||||
public object_property $branding; // The branding of the department
|
||||
public object_property $longitude; // The longitude of the department (Can be null)
|
||||
public object_property $latitude; // The latitude of the department (Can be null)
|
||||
public object_property $created_at;
|
||||
public object_property $updated_at;
|
||||
|
||||
@@ -75,6 +77,8 @@ class departments_o extends db
|
||||
$this->dimension = new object_property($this->table, $this->id, 'dimension', 'int', false);
|
||||
$this->branding = new object_property($this->table, $this->id, 'branding', 'int', false);
|
||||
$this->visible = new object_property($this->table, $this->id, 'visible', 'int', false);
|
||||
$this->longitude = new object_property($this->table, $this->id, 'longitude', 'float', false);
|
||||
$this->latitude = new object_property($this->table, $this->id, 'latitude', 'float', false);
|
||||
$this->created_at = new object_property($this->table, $this->id, 'created_at', 'string', false);
|
||||
$this->updated_at = new object_property($this->table, $this->id, 'updated_at', 'string', false);
|
||||
}
|
||||
@@ -293,6 +297,8 @@ class departments_o extends db
|
||||
'economic_department_id' => (int)$this->economic_department_id->value(),
|
||||
'dimension' => (int)$this->dimension->value(),
|
||||
'branding' => (int)$this->branding->value(),
|
||||
'longitude' => (float)$this->longitude->value(),
|
||||
'latitude' => (float)$this->latitude->value(),
|
||||
'created_at' => (string)$this->created_at->value(),
|
||||
'updated_at' => (string)$this->updated_at->value(),
|
||||
];
|
||||
|
||||
@@ -45,7 +45,9 @@ class departmentsRoute
|
||||
'name',
|
||||
'description',
|
||||
'economic_department_id',
|
||||
'visible'
|
||||
'visible',
|
||||
'longitude',
|
||||
'latitude',
|
||||
])
|
||||
->listObjectsWithPaginationIfSet(
|
||||
function ($department) use ($user) {
|
||||
@@ -58,6 +60,8 @@ class departmentsRoute
|
||||
'updated_at' => (string)$department['updated_at'],
|
||||
'dimension' => (int)$department['dimension'],
|
||||
'branding' => (int)$department['branding'],
|
||||
'longitude' => (float)$department['longitude'],
|
||||
'latitude' => (float)$department['latitude']
|
||||
];
|
||||
// If the user has the permission to view the slack webhook, add it to the response
|
||||
if ($user->hasPermission('view_slack_webhook')) {
|
||||
@@ -143,6 +147,12 @@ class departmentsRoute
|
||||
if (self::isParametersSet(['economic_department_id'])) {
|
||||
$department->economic_department_id->set(self::getParameter('economic_department_id'));
|
||||
}
|
||||
if (self::isParametersSet(['latitude'])) {
|
||||
$department->latitude->set(self::getParameter('latitude'));
|
||||
}
|
||||
if (self::isParametersSet(['longitude'])) {
|
||||
$department->longitude->set(self::getParameter('longitude'));
|
||||
}
|
||||
// Log the incident
|
||||
(new logs_o())->add('departments', (int)self::getParameter('id'), 1, $user->id, 'EDIT_DEPARTMENT', 'Successfully edited a department');
|
||||
// Return a success message
|
||||
|
||||
Reference in New Issue
Block a user