diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php index 50bc3ee548..e6060bf656 100644 --- a/app/Factory/TagFactory.php +++ b/app/Factory/TagFactory.php @@ -58,20 +58,19 @@ class TagFactory { $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']; + $longitude = 0.0 === (float)$data['longitude'] ? null : (float)$data['longitude']; + $array = [ + 'user_id' => $this->user->id, + 'tag' => trim($data['tag']), + 'tagMode' => 'nothing', + 'date' => $data['date'], + 'description' => $data['description'], + 'latitude' => $latitude, + 'longitude' => $longitude, + 'zoomLevel' => $zoomLevel, + ]; - return Tag::create( - [ - 'user_id' => $this->user->id, - 'tag' => trim($data['tag']), - 'tagMode' => 'nothing', - 'date' => $data['date'], - 'description' => $data['description'], - 'latitude' => $latitude, - 'longitude ' => $longitude, - 'zoomLevel' => $zoomLevel, - ] - ); + return Tag::create($array); } /** diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 7dba1172fa..040a9a89dd 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -33,6 +33,7 @@ use FireflyIII\Support\Http\Controllers\PeriodOverview; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Collection; +use Log; /** * Class TagController. @@ -250,7 +251,10 @@ class TagController extends Controller public function store(TagFormRequest $request): RedirectResponse { $data = $request->collectTagData(); - $this->repository->store($data); + Log::debug('Data from request', $data); + + $result = $this->repository->store($data); + Log::debug('Data after storage', $result->toArray()); session()->flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']])); app('preferences')->mark(); diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 87f5b6eca5..81da7a97b3 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -40,8 +40,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property int $id * @property \Carbon\Carbon $date * @property int zoomLevel - * @property float longitude * @property float latitude + * @property float longitude * @property string description * @property string amount_sum * @property string tagMode @@ -64,9 +64,11 @@ class Tag extends Model 'deleted_at' => 'datetime', 'date' => 'date', 'zoomLevel' => 'int', + 'latitude' => 'float', + 'longitude' => 'float', ]; /** @var array Fields that can be filled */ - protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode']; + protected $fillable = ['user_id', 'tag', 'date', 'description', 'latitude', 'longitude', 'zoomLevel', 'tagMode']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index f6db933e0a..b3f074b4dd 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -253,10 +253,9 @@ class TagRepository implements TagRepositoryInterface public function store(array $data): Tag { /** @var TagFactory $factory */ - $factory = new TagFactory; + $factory = app(TagFactory::class); $factory->setUser($this->user); return $factory->create($data); - } /** diff --git a/resources/views/v1/form/location.twig b/resources/views/v1/form/location.twig index 939bef8ff3..9b789bae62 100644 --- a/resources/views/v1/form/location.twig +++ b/resources/views/v1/form/location.twig @@ -1,7 +1,7 @@
{{ trans('firefly.mapbox_api_key')|raw }}
@@ -42,7 +42,7 @@