Update API for tags.

This commit is contained in:
James Cole
2018-12-07 07:41:12 +01:00
parent 01e789f5ce
commit 3e84f9664f
9 changed files with 101 additions and 113 deletions

View File

@@ -34,6 +34,11 @@ use Log;
*/
class TagFactory
{
/** @var Collection */
private $tags;
/** @var User */
private $user;
/**
* Constructor.
*/
@@ -44,11 +49,6 @@ class TagFactory
}
}
/** @var Collection */
private $tags;
/** @var User */
private $user;
/**
* @param array $data
*
@@ -56,6 +56,10 @@ class TagFactory
*/
public function create(array $data): ?Tag
{
$zoomLevel = 0 === (int)$data['zoom_level'] ? null : (int)$data['zoom_level'];
$latitude = 0.0 === (float)$data['latitude'] ? null : (float)$data['latitude'];
$longitude = 0.0 === (float)$data['longitude'] ? null : (int)$data['longitude'];
return Tag::create(
[
'user_id' => $this->user->id,
@@ -63,9 +67,9 @@ class TagFactory
'tagMode' => 'nothing',
'date' => $data['date'],
'description' => $data['description'],
'latitude' => $data['latitude'],
'longitude ' => $data['longitude'],
'zoomLevel' => $data['zoom_level'],
'latitude' => $latitude,
'longitude ' => $longitude,
'zoomLevel' => $zoomLevel,
]
);
}