Same but for tags.

This commit is contained in:
James Cole
2019-12-30 21:04:22 +01:00
parent e1186b48ec
commit a331b2d661
5 changed files with 61 additions and 32 deletions

View File

@@ -23,8 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Models\Tag;
/**
* Class TagStoreRequest
*
@@ -52,13 +50,19 @@ class TagStoreRequest extends Request
*/
public function getAll(): array
{
$hasLocation = false;
if ($this->has('longitude') && $this->has('latitude') && $this->has('zoom_level')) {
$hasLocation = true;
}
return [
'tag' => $this->string('tag'),
'date' => $this->date('date'),
'description' => $this->string('description'),
'latitude' => '' === $this->string('latitude') ? null : $this->string('latitude'),
'longitude' => '' === $this->string('longitude') ? null : $this->string('longitude'),
'zoom_level' => $this->integer('zoom_level'),
'tag' => $this->string('tag'),
'date' => $this->date('date'),
'description' => $this->string('description'),
'has_location' => $hasLocation,
'longitude' => $this->string('longitude'),
'latitude' => $this->string('latitude'),
'zoom_level' => $this->integer('zoom_level'),
];
}

View File

@@ -51,13 +51,19 @@ class TagUpdateRequest extends Request
*/
public function getAll(): array
{
$updateLocation = false;
if ($this->has('longitude') && $this->has('latitude') && $this->has('zoom_level')) {
$updateLocation = true;
}
return [
'tag' => $this->string('tag'),
'date' => $this->date('date'),
'description' => $this->string('description'),
'latitude' => '' === $this->string('latitude') ? null : $this->string('latitude'),
'longitude' => '' === $this->string('longitude') ? null : $this->string('longitude'),
'zoom_level' => $this->integer('zoom_level'),
'tag' => $this->string('tag'),
'date' => $this->date('date'),
'description' => $this->string('description'),
'has_location' => $updateLocation,
'longitude' => '' === $this->string('longitude') ? null : $this->string('longitude'),
'latitude' => '' === $this->string('latitude') ? null : $this->string('latitude'),
'zoom_level' => '' === $this->string('zoom_level') ? null : $this->integer('zoom_level'),
];
}