mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 07:38:29 +00:00
Fix location store for tag.
This commit is contained in:
@@ -355,20 +355,21 @@ class Request extends FormRequest
|
||||
*/
|
||||
protected function appendLocationData(array $data, ?string $prefix): array
|
||||
{
|
||||
Log::debug(sprintf('Now in appendLocationData(%s)', $prefix), $data);
|
||||
Log::debug(sprintf('Now in appendLocationData("%s")', $prefix), $data);
|
||||
$data['store_location'] = false;
|
||||
$data['update_location'] = false;
|
||||
$data['longitude'] = null;
|
||||
$data['latitude'] = null;
|
||||
$data['zoom_level'] = null;
|
||||
|
||||
|
||||
$longitudeKey = null === $prefix ? 'longitude' : sprintf('%s_longitude', $prefix);
|
||||
$latitudeKey = null === $prefix ? 'latitude' : sprintf('%s_latitude', $prefix);
|
||||
$zoomLevelKey = null === $prefix ? 'zoom_level' : sprintf('%s_zoom_level', $prefix);
|
||||
|
||||
// for a POST (store, all fields must be present and accounted for:
|
||||
if (
|
||||
('POST' === $this->method() && ($this->routeIs('accounts.store') || $this->routeIs('api.v1.accounts.store')))
|
||||
('POST' === $this->method() && $this->routeIs('*.store'))
|
||||
&& ($this->has($longitudeKey) && $this->has($latitudeKey) && $this->has($zoomLevelKey))
|
||||
) {
|
||||
Log::debug('Method is POST and all fields present.');
|
||||
@@ -380,8 +381,8 @@ class Request extends FormRequest
|
||||
if (
|
||||
($this->has($longitudeKey) && $this->has($latitudeKey) && $this->has($zoomLevelKey))
|
||||
&& (
|
||||
('PUT' === $this->method() && $this->routeIs('api.v1.accounts.update'))
|
||||
|| ('POST' === $this->method() && $this->routeIs('accounts.update'))
|
||||
('PUT' === $this->method() && $this->routeIs('*.update'))
|
||||
|| ('POST' === $this->method() && $this->routeIs('*.update'))
|
||||
)
|
||||
) {
|
||||
Log::debug('Method is PUT and all fields present.');
|
||||
|
||||
@@ -48,26 +48,13 @@ class TagFormRequest extends Request
|
||||
*/
|
||||
public function collectTagData(): array
|
||||
{
|
||||
$latitude = null;
|
||||
$longitude = null;
|
||||
$zoomLevel = null;
|
||||
$hasLocation = false;
|
||||
if (true === $this->boolean('location_has_location')) {
|
||||
$latitude = $this->string('location_latitude');
|
||||
$longitude = $this->string('location_longitude');
|
||||
$zoomLevel = $this->integer('location_zoom_level');
|
||||
$hasLocation = true;
|
||||
}
|
||||
|
||||
return [
|
||||
'tag' => $this->string('tag'),
|
||||
'date' => $this->date('date'),
|
||||
'description' => $this->string('description'),
|
||||
'latitude' => $latitude,
|
||||
'longitude' => $longitude,
|
||||
'zoom_level' => $zoomLevel,
|
||||
'has_location' => $hasLocation,
|
||||
$data = [
|
||||
'tag' => $this->string('tag'),
|
||||
'date' => $this->date('date'),
|
||||
'description' => $this->string('description'),
|
||||
];
|
||||
return $this->appendLocationData($data, 'location');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user